Filter
uncanny-automator
automator_register_closure_integration
Filters the closure integration before it is registered, allowing for modification of the integration, closure, or code.
add_filter( 'automator_register_closure_integration', $callback, 10, 3 );
Description
Allows modification of integration details before registration. Developers can alter the integration object, closure, or integration code. Primarily for advanced customization of core integrations.
Usage
add_filter( 'automator_register_closure_integration', 'your_function_name', 10, 3 );
Parameters
-
$integration(mixed) - This parameter contains the integration object being registered, which can be modified by the filter.
-
$closure(mixed) - This parameter contains the integration object or data that is being registered.
-
$integration_code(mixed) - This parameter contains a closure that will be registered as an integration within the automator system.
Return Value
The filtered value.
Examples
<?php
/**
* Example usage of the 'automator_register_closure_integration' filter.
*
* This filter allows modifying or replacing an integration object before it's registered.
* In this example, we'll check if the integration is for a specific plugin and
* add an extra property to it if it meets certain criteria.
*/
add_filter(
'automator_register_closure_integration',
function ( $integration, $closure, $integration_code ) {
// Check if the integration_code corresponds to a specific plugin we want to interact with.
// Replace 'my_custom_integration' with an actual integration code from your system.
if ( 'my_custom_integration' === $integration_code ) {
// Assume $integration is an object that can have properties added.
// We'll add a flag to indicate it's been modified by our hook.
if ( is_object( $integration ) ) {
$integration->modified_by_custom_hook = true;
$integration->custom_message = 'This integration was enhanced by a custom filter!';
}
// You could also potentially replace the entire integration object if needed,
// but be sure it conforms to the expected structure.
// For example:
// $new_integration = new MyCustomIntegrationObject();
// return $new_integration;
}
// Always return the integration object (modified or not) to ensure proper registration.
return $integration;
},
10, // Priority: Lower numbers execute earlier.
3 // Accepted arguments: We are accepting $integration, $closure, and $integration_code.
);
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/lib/utilities/class-automator-registration.php:490
$integration,
$closure,
$integration_code,
),
'3.0',
'automator_register_closure_integration'
);
$integration = apply_filters( 'automator_register_closure_integration', $integration, $closure, $integration_code );
//$integrations = Automator()->get_integrations();
// Integration was passed in, lets try to register it
if ( null !== $integration_code ) {
if ( ! is_string( $integration_code ) ) {
throw new Automator_Exception( 'You are trying to register a closure without passing an proper integration code.', 1004 );
}