automator_integration_items
Filters integration items to modify the available integrations before they are displayed to the user.
add_filter( 'automator_integration_items', $callback, 10, 2 );
Description
This filter allows developers to modify the array of integration items before they are processed. It fires after integration items are structured and sorted. Developers can add, remove, or alter items to customize integration behavior or add new integration types.
Usage
add_filter( 'automator_integration_items', 'your_function_name', 10, 2 );
Parameters
-
$items(mixed) - This parameter contains an array of integration items, which are then sorted by key.
-
$this(mixed) - This parameter contains an array of integration items, which are then sorted alphabetically by their keys.
Return Value
The filtered value.
Examples
/**
* Example function to modify the automator integration items.
* This function might add a new integration item or modify an existing one.
*
* @param array $items The current array of integration items.
* @param object $automator_service The instance of the Automator service class.
* @return array The modified array of integration items.
*/
function my_custom_automator_integration_items( $items, $automator_service ) {
// Example: Add a new custom integration item for a hypothetical plugin.
if ( ! isset( $items['my_custom_plugin'] ) ) {
$items['my_custom_plugin'] = array(
'name' => __( 'My Custom Plugin Integration', 'my-text-domain' ),
'description' => __( 'Integration for custom actions and triggers from My Custom Plugin.', 'my-text-domain' ),
'actions' => array(), // Placeholder for custom actions
'triggers' => array(), // Placeholder for custom triggers
'conditions' => array(), // Placeholder for custom conditions
'loop_filters' => array(), // Placeholder for custom loop filters
);
}
// Example: Modify an existing item, perhaps adding a new action type.
if ( isset( $items['some_existing_integration'] ) && is_array( $items['some_existing_integration'] ) ) {
$items['some_existing_integration']['actions']['custom_action_for_existing'] = array(
'name' => __( 'Perform a Custom Action', 'my-text-domain' ),
'description' => __( 'Triggers a unique action within the existing integration.', 'my-text-domain' ),
'fields' => array(
array(
'name' => 'custom_setting',
'label' => __( 'Custom Setting', 'my-text-domain' ),
'type' => 'text',
),
),
);
}
// Always return the modified items array.
return $items;
}
add_filter( 'automator_integration_items', 'my_custom_automator_integration_items', 10, 2 );
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/integrations/structure.php:513
src/api/components/token/integration/registry/class-wp-integration-token-registry.php:169
'conditions' => $this->restructure_conditions( $code ),
'loop_filters' => isset( $filters[ $code ] ) ? $filters[ $code ] : array(),
);
}
ksort( $items );
$this->structure = apply_filters( 'automator_integration_items', $items, $this );
return $this;
}
/**
* Restructures the conditions to append the fields of the conditions that are active in the recipe.
*
Internal Usage
Found in src/core/services/loopable/universal-loopable-token.php:60:
add_filter( 'automator_integration_items', array( $this, 'register_token' ), 90, 2 );
Found in src/core/lib/recipe-parts/tokens/abstract-token.php:30:
add_filter( 'automator_integration_items', array( $this, 'register_token' ), 10, 2 );
Found in src/core/lib/recipe-parts/tokens/abstract-universal-token.php:26:
add_filter( 'automator_integration_items', array( $this, 'register_token' ), 10, 2 );