Filter
uncanny-automator
automator_thrive_ovation_validate_common_possible_triggers_tokens
Filters possible triggers and tokens for Thrive Ovation's testimonial submission automations.
add_filter( 'automator_thrive_ovation_validate_common_possible_triggers_tokens', $callback, 10, 1 );
Description
Filters the possible trigger tokens for Thrive Ovation integrations. Developers can add or remove tokens from the default 'TVO_TESTIMONIAL_SUBMITTED' list, allowing custom trigger options for specific automation scenarios.
Usage
add_filter( 'automator_thrive_ovation_validate_common_possible_triggers_tokens', 'your_function_name', 10, 1 );
Parameters
-
$args(mixed) - This parameter contains an array of valid Thrive Ovation trigger codes that can be used with the integration.
Return Value
The filtered value.
Examples
add_filter( 'automator_thrive_ovation_validate_common_possible_triggers_tokens', 'my_custom_tvo_possible_tokens', 10, 2 );
/**
* Adds a custom token validation for Thrive Ovation triggers.
*
* This example demonstrates how to add a new trigger code to be considered
* valid for common Thrive Ovation tokens. In a real scenario, you might
* have custom triggers that also need to be recognized by the system.
*
* @param array $trigger_meta_validations The array of valid trigger codes.
* @param array $args The arguments passed to the filter.
*
* @return array The modified array of valid trigger codes.
*/
function my_custom_tvo_possible_tokens( $trigger_meta_validations, $args ) {
// Check if the current trigger code being processed is a custom one we want to support.
// For demonstration, let's assume we have a custom trigger code like 'MY_CUSTOM_TVO_TRIGGER'.
// You would replace this with your actual custom trigger code logic.
$current_trigger_code = isset( $args['triggers_meta']['code'] ) ? $args['triggers_meta']['code'] : '';
// If it's a trigger we want to enable for common tokens, add it to the list.
// In a real plugin, you'd have a more robust way to check if it's your plugin's trigger.
if ( 'MY_CUSTOM_TVO_TRIGGER' === $current_trigger_code ) {
$trigger_meta_validations[] = 'MY_CUSTOM_TVO_TRIGGER';
}
return $trigger_meta_validations;
}
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/integrations/thrive-ovation/tokens/thrive-ovation-tokens.php:67
public function thrive_ovation_possible_tokens( $tokens = array(), $args = array() ) {
$trigger_code = (string) $args['triggers_meta']['code'];
$trigger_meta_validations = apply_filters(
'automator_thrive_ovation_validate_common_possible_triggers_tokens',
array( 'TVO_TESTIMONIAL_SUBMITTED' ),
$args
);
if ( ! in_array( $trigger_code, $trigger_meta_validations, true ) ) {
return $tokens;
}
$fields = array(
array(
'tokenId' => 'TESTIMONIAL_ID',
'tokenName' => esc_html__( 'Testimonial ID', 'uncanny-automator' ),
'tokenType' => 'int',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_TITLE',
'tokenName' => esc_html__( 'Testimonial title', 'uncanny-automator' ),
'tokenType' => 'text',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_CONTENT',
'tokenName' => esc_html__( 'Testimonial content', 'uncanny-automator' ),
'tokenType' => 'text',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_DATE',
'tokenName' => esc_html__( 'Date', 'uncanny-automator' ),
'tokenType' => 'date',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_AUTHOR',
'tokenName' => esc_html__( 'Full name', 'uncanny-automator' ),
'tokenType' => 'text',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_AUTHOR_EMAIL',
'tokenName' => esc_html__( 'Email', 'uncanny-automator' ),
'tokenType' => 'email',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_AUTHOR_ROLE',
'tokenName' => esc_html__( 'Role/Occupation', 'uncanny-automator' ),
'tokenType' => 'text',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_AUTHOR_WEBSITE',
'tokenName' => esc_html__( 'Website URL', 'uncanny-automator' ),
'tokenType' => 'url',
'tokenIdentifier' => $trigger_code,
),
array(
'tokenId' => 'TESTIMONIAL_STATUS',
'tokenName' => esc_html__( 'Testimonial status', 'uncanny-automator' ),
'tokenType' => 'text',
'tokenIdentifier' => $trigger_code,
),
);
$tokens = array_merge( $tokens, $fields );
return $tokens;
}