Wpwh_Helpers::match_action_condition( $action, null|array $recipes = null, null|string $trigger_meta = null, null|string $trigger_code = null, null|string $trigger_second_code = null )

Match condition for form field and value.


Parameters Parameters

$action

(Required)

$recipes

(null|array) (Optional) .

Default value: null

$trigger_meta

(null|string) (Optional) .

Default value: null

$trigger_code

(null|string) (Optional) .

Default value: null

$trigger_second_code

(null|string) (Optional) .

Default value: null


Top ↑

Return Return

(array|bool)


Source Source

File: src/integrations/wp-webhooks/helpers/wpwh-helpers.php

	public function match_action_condition( $action, $recipes = null, $trigger_meta = null, $trigger_code = null, $trigger_second_code = null ) {
		if ( null === $recipes ) {
			return false;
		}

		$recipe_ids = array();

		//Limiting to specific recipe IDs
		foreach ( $recipes as $recipe ) {
			foreach ( $recipe['triggers'] as $trigger ) {
				if ( key_exists( $trigger_meta, $trigger['meta'] ) && $trigger['meta'][ $trigger_meta ] === $action ) {
					$recipe_ids[ $recipe['ID'] ] = $recipe['ID'];
					break;
				}
			}
		}


		if ( ! empty( $recipe_ids ) ) {
			return [ 'recipe_ids' => $recipe_ids, 'result' => true ];
		}

		return false;
	}