Filter uncanny-automator

automator_recipe_import_published_trigger_codes

Filters the published trigger codes available for import into Automator recipes.

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

Description

Allows developers to modify the list of trigger codes for published recipes during an import. Use this filter to add, remove, or alter trigger codes that will be associated with imported recipes, ensuring accurate functionality and integration with your custom triggers.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example: Add a custom trigger code to the published triggers list during recipe import.
 *
 * This function demonstrates how to filter the `automator_recipe_import_published_trigger_codes`
 * hook to add a new, custom trigger code that should be considered "published" when importing a recipe.
 *
 * @param array $published_trigger_codes The array of currently published trigger codes.
 * @return array The modified array of published trigger codes.
 */
add_filter( 'automator_recipe_import_published_trigger_codes', function ( $published_trigger_codes ) {
    // Assuming 'my_custom_trigger_slug' is a valid trigger slug registered elsewhere in the plugin.
    // We add it to the list of published triggers so that if a recipe being imported
    // uses this trigger, it's recognized and processed correctly.
    $published_trigger_codes['my_custom_trigger_slug'] = 'My Custom Trigger'; // The key is the slug, the value is the display name.

    // You might also want to ensure that the trigger is actually registered and available.
    // For a realistic example, you'd likely have a more robust check here, perhaps
    // by querying a list of all available trigger slugs.

    return $published_trigger_codes;
}, 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/core/admin/class-import-recipe.php:283

public function pre_import_filters() {
		$this->draft_post_types        = apply_filters( 'automator_recipe_import_draft_post_types', $this->draft_post_types );
		$this->published_trigger_codes = apply_filters( 'automator_recipe_import_published_trigger_codes', $this->published_trigger_codes );

		// Maybe adjust hardcoded meta URLs.
		add_filter( 'automator_recipe_part_meta_value', array( $this, 'maybe_adjust_hardcoded_meta_urls' ), 10, 4 );
	}


Scroll to Top