Filter
Dynamic
uncanny-automator
automator_integration_settings_instance_{dynamic}
> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Filters integration settings for a specific instance before it's saved or displayed.
add_filter( 'automator_integration_settings_instance_{dynamic}', $callback, 10, 1 );
Description
Fires to retrieve an integration's settings instance. Developers can use this hook to filter and modify the integration instance before it's used. The dynamic part of the hook name corresponds to the integration ID. It fires after an integration ID is validated but before the instance is fetched.
Usage
add_filter( 'automator_integration_settings_instance_{dynamic}', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example of how to hook into the 'automator_integration_settings_instance_{dynamic}' filter.
* This hook allows you to provide a specific integration instance based on the integration ID.
*
* @param mixed|null $integration The default value passed to the filter, usually null.
* @param string $integration_id The ID of the integration being requested.
*
* @return object|null An instance of your custom integration class, or null if not handled.
*/
add_filter(
'automator_integration_settings_instance_my_custom_integration',
function ( $integration, $integration_id ) {
// This logic assumes you have a custom integration class registered somewhere.
// For demonstration purposes, let's imagine a class named 'My_Custom_Automator_Integration'.
// In a real scenario, you'd likely check if this integration ID is one you handle.
// If the integration ID matches what we're looking for, return an instance of our integration.
if ( 'my_custom_integration' === $integration_id ) {
// Instantiate your custom integration class.
// You might pass specific configurations or dependencies here.
return new My_Custom_Automator_Integration();
}
// If it's not our integration, return the original value (null in this case).
return $integration;
},
10, // Priority: standard priority for filters.
2 // Accepted args: the filter receives the default value and the integration ID.
);
// Dummy class for demonstration purposes.
// In a real plugin, this class would contain the actual logic for your integration.
if ( ! class_exists( 'My_Custom_Automator_Integration' ) ) {
class My_Custom_Automator_Integration {
// Add methods and properties relevant to your integration here.
public function get_name() {
return 'My Custom Integration';
}
}
}
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
src/core/services/app-integrations/action-manager.php:307
private function get_integration_settings_instance( $integration_id ) {
// Check if the integration ID is valid
if ( empty( $integration_id ) ) {
throw new Exception( 'Invalid request' );
}
// Get integration via filter
$integration = apply_filters(
'automator_integration_settings_instance_' . sanitize_key( $integration_id ),
null
);
if ( ! $integration ) {
throw new Exception(
esc_html_x(
"Integration not found",
'Integration settings',
'uncanny-automator'
)
);
}
return $integration;
}