Filter uncanny-automator

automator_api_url

Filters the Automator API URL, allowing modification before it's used for plugin communication.

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

Description

Filters the base URL for the Automator plugin's API. Developers can use this hook to redirect API requests to a custom endpoint, useful for self-hosted or private installations. The default value is the official Automator API URL.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Modify the Automator API URL to point to a staging environment for testing.
 *
 * This filter allows developers to change the default API endpoint, useful for
 * testing against a staging or development server without affecting the live site.
 *
 * @param string $api_url The default API URL.
 * @return string The modified API URL.
 */
add_filter( 'automator_api_url', function( $api_url ) {
    // In a development environment, you might want to use a local or staging API.
    // This check ensures we only change it if a specific constant is defined,
    // or based on some other environment detection logic.
    if ( defined( 'AUTOMATOR_DEV_MODE' ) && AUTOMATOR_DEV_MODE ) {
        return 'https://staging.api.automatorplugin.com/';
    }
    return $api_url; // Return the original URL if not in development mode.
}, 10, 1 );

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/globals.php:47
src/core/classes/class-api-server.php:56

/**
	 * Automator ABSPATH for automator logs directory
	 */
	define( 'UA_DEBUG_LOGS_DIR', trailingslashit( UA_ABSPATH ) . 'logs' . DIRECTORY_SEPARATOR );
}

if ( ! defined( 'AUTOMATOR_API_URL' ) ) {
	define( 'AUTOMATOR_API_URL', apply_filters( 'automator_api_url', 'https://api.automatorplugin.com/' ) );
}

if ( ! defined( 'AUTOMATOR_LOGS_EXT' ) ) {
	define( 'AUTOMATOR_LOGS_EXT', apply_filters( 'automator_logs_extension', 'log' ) );
}

if ( ! defined( 'AUTOMATOR_SITE_KEY' ) ) {


Scroll to Top