Filter uncanny-automator

automator_localized_strings

Filters localized strings for the Automator plugin, allowing modification of text used in the WordPress admin area.

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

Description

Allows developers to modify or add to the localized strings used by the Automator core. This filter is applied after all default strings are loaded, providing a central point to customize text for internationalization or specific integrations. Use it to translate UI elements or add custom messages.


Usage

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

Parameters

$this (mixed)
This parameter contains an array of localized strings that are made available to the WordPress frontend and backend for the Automator plugin.

Return Value

The filtered value.


Examples

/**
 * Example of how to modify the localized strings for the Automator plugin.
 *
 * This function intercepts the 'automator_localized_strings' filter and adds a custom string
 * or modifies an existing one.
 *
 * @param array $localized_strings The array of localized strings.
 * @return array The modified array of localized strings.
 */
add_filter(
	'automator_localized_strings',
	function ( $localized_strings ) {
		// Add a new custom string for a specific UI element.
		$localized_strings['custom_button_text'] = __( 'Run Automation Now', 'your-text-domain' );

		// Example: Modify an existing string if it exists.
		if ( isset( $localized_strings['trigger_added_success'] ) ) {
			$localized_strings['trigger_added_success'] = sprintf(
				/* translators: %s: Name of the trigger. */
				__( 'Great! Your trigger "%s" has been successfully added.', 'your-text-domain' ),
				'New Trigger Name' // This could be dynamically determined if needed
			);
		}

		// Return the modified array of strings.
		return $localized_strings;
	},
	10, // Priority: Default WordPress priority.
	1   // Accepted Args: The filter hook only passes one argument ($this in the source context, which is an array of strings here).
);

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/utilities/class-automator-translations.php:97

public function get_all() {
		$this->set_strings();
		$this->ls          = apply_filters_deprecated( 'uap_localized_strings', array( $this->ls ), '3.0', 'automator_localized_strings' );
		$localized_strings = apply_filters( 'automator_localized_strings', $this->ls );

		return $localized_strings;
	}


Scroll to Top