Filter
uncanny-automator
automator_integration_icon_path
Filters the path to an integration's icon, allowing customization before it's used.
add_filter( 'automator_integration_icon_path', $callback, 10, 4 );
Description
Filters the path to an integration's icon. Developers can use this hook to dynamically change the icon's location or filename based on specific integration needs. The hook provides the default path, the icon filename, the integration directory name, and the plugin's root path for context.
Usage
add_filter( 'automator_integration_icon_path', 'your_function_name', 10, 4 );
Parameters
-
$path(mixed) - This parameter holds the default or current path to the integration icon.
-
$icon(mixed) - The path to the integration icon file, which can be either a full path or a relative path.
-
$integration_dir(mixed) - This parameter contains the name of the icon file for the integration.
-
$plugin_path(mixed) - This parameter contains the directory path where the integration is located.
Return Value
The filtered value.
Examples
<?php
/**
* Example: Modify the icon path for Automator integrations.
*
* This filter allows you to change the default path where Automator looks for
* integration icons. For instance, you might want to load icons from a
* custom directory or rename them based on certain conditions.
*
* In this example, we'll append a '/custom/' prefix to the icon path
* if the integration is for 'my-custom-integration'.
*/
add_filter(
'automator_integration_icon_path',
function ( $path, $icon, $integration_dir, $plugin_path ) {
// Check if this is a specific integration we want to modify.
if ( 'my-custom-integration' === $integration_dir ) {
// Prepend a custom directory to the path.
$path = 'custom/' . $path;
}
// Return the modified or original path.
return $path;
},
10, // Priority: Default is 10.
4 // Accepted arguments: The filter passes 4 arguments.
);
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/class-utilities.php:219
public static function automator_get_integration_icon( $file_name, $plugin_path = AUTOMATOR_BASE_FILE ) {
/**
* Integration icons are now moved in to integrations itself
*
* @since 3.0
*/
if ( ! empty( $file_name ) && is_dir( dirname( $file_name ) ) ) {
$icon = basename( $file_name ); // icon with extension.
$integration_dir = basename( dirname( $file_name ) ); // integration folder path.
$path = self::cleanup_icon_path( $plugin_path, $icon, $file_name ); // path relative to plugin.
$path = apply_filters( 'automator_integration_icon_path', $path . $icon, $icon, $integration_dir, $plugin_path );
$base_path = apply_filters( 'automator_integration_icon_base_path', $plugin_path, $path, $icon, $integration_dir );
if ( ! empty( $path ) && ! empty( $base_path ) ) {
return plugins_url( $path, $base_path );
}
}
// fallback
$path = apply_filters( 'automator_integration_icon_path_legacy', 'src/recipe-ui/dist/media/integrations/' . $file_name, $file_name, $plugin_path );
$base_path = apply_filters( 'automator_integration_icon_base_path_legacy', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $plugin_path, $file_name );
if ( ! empty( $path ) && ! empty( $base_path ) ) {
return plugins_url( $path, $base_path );
}
return '';
}