Filter uncanny-automator

automator_recipe_bulk_export_filename

Filters the filename used when bulk exporting Automator recipes, allowing customization before the export.

add_filter( 'automator_recipe_bulk_export_filename', $callback, 10, 2 );

Description

Allows modification of the default filename for bulk recipe exports. Developers can alter the generated filename string, which defaults to a timestamped format like 'recipes-YYYY-MM-DD-HH-MM-SS', before the export file is created.


Usage

add_filter( 'automator_recipe_bulk_export_filename', 'your_function_name', 10, 2 );

Parameters

$filename (mixed)
This parameter holds the dynamically generated filename for the bulk recipe export, which includes a timestamp.
$recipe_ids (mixed)
This parameter holds the default filename for the bulk recipe export, which includes the current date and time.

Return Value

The filtered value.


Examples

add_filter( 'automator_recipe_bulk_export_filename', 'my_custom_recipe_export_filename', 10, 2 );

/**
 * Customizes the filename for bulk recipe exports.
 *
 * This example appends the count of exported recipes to the filename.
 *
 * @param string $filename   The default filename.
 * @param array  $recipe_ids An array of recipe IDs being exported.
 *
 * @return string The modified filename.
 */
function my_custom_recipe_export_filename( $filename, $recipe_ids ) {
	$recipe_count = count( $recipe_ids );
	// Append the number of recipes to the default filename.
	return $filename . '-' . $recipe_count . '-recipes.json';
}

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-export-recipe.php:350

public function generate_bulk_export_filename( $recipe_ids ) {
		$filename = 'recipes-' . wp_date( 'Y-m-d-H-i-s' );

		return apply_filters( 'automator_recipe_bulk_export_filename', $filename, $recipe_ids );
	}


Scroll to Top