Filter uncanny-automator-pro

automator_pro_loop_process_secret

Filters the secret token used for processing loops, allowing customization before it's utilized.

add_filter( 'automator_pro_loop_process_secret', $callback, 10, 1 );

Description

Allows developers to modify the secret token used for internal loop processing. This filter hook fires before the `Auth` object is instantiated, enabling customization of the authentication secret. Developers can leverage this to integrate custom authentication mechanisms or dynamically generate secrets.


Usage

add_filter( 'automator_pro_loop_process_secret', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Example of how to filter the secret used for authentication in the Uncanny Automator Pro loop.
 *
 * This example demonstrates how to override the default empty secret with a custom token
 * retrieved from a secure WordPress option. In a real-world scenario, this option
 * would be set through the WordPress admin area.
 *
 * @param mixed $secret The current secret value.
 * @return string The filtered secret, either the original or a custom one.
 */
add_filter( 'automator_pro_loop_process_secret', 'my_custom_automator_loop_secret', 10, 1 );

function my_custom_automator_loop_secret( $secret ) {
    // In a real application, you would securely retrieve this secret.
    // For demonstration, we'll try to get it from a custom option.
    $custom_secret = get_option( 'uncanny_automator_pro_loop_api_key' );

    // If a custom secret is found in our option, use it. Otherwise, stick with the default (empty).
    if ( ! empty( $custom_secret ) ) {
        $secret = $custom_secret;
    }

    // It's crucial to return the filtered value.
    return $secret;
}

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

uncanny-automator-pro/src/global-functions.php:78

function automator_pro_loop_auth_token() {

	static $instance = null;

	if ( null === $instance ) {
		$secret   = apply_filters( 'automator_pro_loop_process_secret', '' );
		$instance = new Auth( $secret );
	}

	return $instance;
}


Scroll to Top