Filter
uncanny-automator
uap_meta_box_title
Filters the title displayed for the triggers meta box, allowing customization of the heading text.
add_filter( 'uap_meta_box_title', $callback, 10, 1 );
Description
Filters the title of the "Triggers" meta box in Uncanny Automator recipes. Developers can use this to customize the default "Triggers" text, perhaps to be more specific based on the recipe type or other contextual information.
Usage
add_filter( 'uap_meta_box_title', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to hook into the 'uap_meta_box_title' filter.
*
* This example customizes the title of the "Triggers" meta box based on
* whether a specific recipe type has been selected, potentially making it
* singular ("Trigger") for certain types.
*
* @param string $title The current title of the meta box.
* @param string|null $recipe_type The type of recipe being edited (e.g., 'anonymous', 'logged-in').
* @return string The modified title for the meta box.
*/
add_filter( 'uap_meta_box_title', 'my_custom_uap_meta_box_title', 10, 2 );
function my_custom_uap_meta_box_title( $title, $recipe_type ) {
// If no recipe type is selected yet, use the default title.
if ( empty( $recipe_type ) ) {
return $title;
}
// For 'anonymous' recipe types, we might want to use a singular "Trigger" title.
// The original code already handles this, but this demonstrates how you'd modify it.
if ( 'anonymous' === (string) $recipe_type ) {
// Let's say we want to make it even more specific for anonymous types.
return esc_attr__( 'An Anonymous Trigger', 'uncanny-automator' );
}
// For any other recipe type, return the default or already filtered title.
return $title;
}
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/automator-post-types/uo-recipe/class-recipe-post-metabox.php:54
src/core/automator-post-types/uo-recipe/class-recipe-post-metabox.php:57
src/core/automator-post-types/uo-recipe/class-recipe-post-metabox.php:59
// Create variable to save the title of the triggers metabox,
// and add the default value (on load value)
/* translators: Trigger type. Logged-in triggers are triggered only by logged-in users */
// Check if the user didn't select a recipe type yet
if ( empty( $recipe_type ) ) {
$triggers_metabox_title = apply_filters( 'uap_meta_box_title', esc_attr__( 'Triggers', 'uncanny-automator' ), $recipe_type );
} else {
if ( 'anonymous' === (string) $recipe_type ) {
$triggers_metabox_title = apply_filters( 'uap_meta_box_title', esc_attr__( 'Trigger', 'uncanny-automator' ), $recipe_type );
} else {
$triggers_metabox_title = apply_filters( 'uap_meta_box_title', esc_attr__( 'Triggers', 'uncanny-automator' ), $recipe_type );
}
}