Automator_Recipe_Process_Complete::triggers_completed( int $recipe_id, int $user_id, int $recipe_log_id, array $args = array() )
Are all triggers in the recipe completed
Parameters Parameters
- $recipe_id
-
(Required) null||int
- $user_id
-
(Required) null||int
- $recipe_log_id
-
(Required) null||int
- $args
-
(Optional)
Default value: array()
Return Return
(bool|null)
Source Source
File: src/core/lib/process/class-automator-recipe-process-complete.php
public function triggers_completed( $recipe_id = 0, $user_id = 0, $recipe_log_id = 0, $args = array() ) { if ( null === $recipe_id || ! is_numeric( $recipe_id ) ) { Automator()->error->add_error( 'triggers_completed', 'ERROR: You are trying to check if triggers are completed without providing a recipe_id.', $this ); return null; } // Set user ID if ( is_null( $user_id ) ) { $user_id = get_current_user_id(); } $recipe_triggers = Automator()->get_recipe_data( 'uo-trigger', $recipe_id ); // By default the recipe will complete unless there is a trigger that is live(publish status) and its NOT completed $triggers_completed = true; foreach ( $recipe_triggers as $recipe_trigger ) { if ( 'publish' === (string) $recipe_trigger['post_status'] ) { $trigger_integration = $recipe_trigger['meta']['integration']; if ( 0 === Automator()->plugin_status->get( $trigger_integration ) ) { // The plugin for this trigger is NOT active Automator()->error->add_error( 'complete_trigger', 'ERROR: You are trying to complete ' . $recipe_trigger['meta']['code'] . ' and the plugin ' . $trigger_integration . ' is not active. @recipe_id ' . $recipe_id, $this ); } $trigger_completed = Automator()->db->trigger->is_completed( $user_id, $recipe_trigger['ID'], $recipe_id, $recipe_log_id, true, $args ); if ( ! $trigger_completed ) { return false; } } } return $triggers_completed; }
Expand full source code Collapse full source code View on Github