Filter uncanny-automator

automator_is_integration_plugin_active

Filters whether an integration plugin is active, allowing customization of its status for AutomatorWP.

add_filter( 'automator_is_integration_plugin_active', $callback, 10, 3 );

Description

Filters whether an integration plugin is considered active. Developers can modify the `$active` boolean value, the `$plugin` path, or the `$this` object to influence the active status check. This hook is applied after WordPress's `is_plugin_active` check, allowing for custom logic.


Usage

add_filter( 'automator_is_integration_plugin_active', 'your_function_name', 10, 3 );

Parameters

$active (mixed)
This parameter contains a boolean value indicating whether the integration plugin is currently active.
$plugin (mixed)
This parameter indicates whether the plugin is currently active.
$this (mixed)
This parameter contains the plugin path that is being checked for activation.

Return Value

The filtered value.


Examples

/**
 * Example of using the 'automator_is_integration_plugin_active' filter hook.
 * This example checks if a specific integration plugin is active.
 * If it is, it returns true. Otherwise, it defaults to the original value.
 *
 * @param bool   $active The current active status of the plugin.
 * @param string $plugin The plugin file path.
 * @param string $original_plugin_path The original plugin file path before modification.
 *
 * @return bool The modified active status.
 */
add_filter( 'automator_is_integration_plugin_active', function( $active, $plugin, $original_plugin_path ) {

	// Define the specific plugin slug we want to check for.
	$target_plugin_slug = 'my-custom-integration/my-custom-integration.php';

	// Compare the provided plugin path with our target slug.
	if ( strpos( $plugin, $target_plugin_slug ) !== false ) {
		// If this is our target plugin and it's already marked as active, return true.
		// Otherwise, we can let the original logic decide or explicitly return false.
		// For this example, we'll just ensure it's true if it's our plugin and $active is already true.
		if ( $active ) {
			return true;
		}
	}

	// If it's not our target plugin, or our target plugin wasn't active,
	// return the original $active value.
	return $active;

}, 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

src/core/lib/recipe-parts/trait-integrations.php:166

public function plugin_active() {
		$plugin = apply_filters( 'automator_modify_plugin_path', $this->get_plugin_file_path() );

		include_once ABSPATH . 'wp-admin/includes/plugin.php';
		$active = ! empty( $plugin ) ? is_plugin_active( $plugin ) : false;

		return apply_filters( 'automator_is_integration_plugin_active', $active, $plugin, $this->get_plugin_file_path() );
	}


Scroll to Top