Automator_Recipe_Process_Complete::parse_custom_value( $action_data, $user_id, $recipe_id, $args )
this code is to parse new “Use custom value” functionality before an action function is called. We will not have to modify each integration to support it.
Parameters Parameters
- $action_data
-
(Required)
- $user_id
-
(Required)
- $recipe_id
-
(Required)
- $args
-
(Required)
Return Return
(mixed)
Source Source
File: src/core/lib/process/class-automator-recipe-process-complete.php
public function parse_custom_value( $action_data, $user_id, $recipe_id, $args ) { if ( ! isset( $action_data['meta'] ) ) { return $action_data; } $updated_values = array(); $meta = $action_data['meta']; // use regex to see if there's a _custom key $custom_keys = preg_grep( '/(automator_custom_value)/', $meta ); if ( ! $custom_keys ) { return $action_data; } foreach ( $custom_keys as $action_meta => $custom_value ) { $k = "{$action_meta}_custom"; if ( ! key_exists( $k, $meta ) ) { continue; } // parse token here $v = Automator()->parse->text( $action_data['meta'][ $k ], $recipe_id, $user_id, $args ); if ( $v ) { $action_data['meta'][ $action_meta ] = $v; $updated_values[ $action_meta ] = $v; } } if ( $updated_values ) { foreach ( $updated_values as $meta_key => $meta_value ) { $pass_args = array( 'user_id' => $user_id, 'trigger_id' => $args['trigger_id'], 'meta_key' => $meta_key, 'meta_value' => $meta_value, 'run_number' => $args['run_number'], //get run number 'trigger_log_id' => $args['trigger_log_id'], ); Automator()->db->trigger->add_meta( $args['trigger_id'], $args['trigger_log_id'], $args['run_number'], $pass_args ); } } return $action_data; }
Expand full source code Collapse full source code View on Github
Changelog Changelog
Version | Description |
---|---|
2.8 | Introduced. |