Fluent_Crm_Helpers::match_single_condition( null|array|string $to_match = null, null $match_type = 'int', null $trigger_meta = null, null $trigger_code = null )


Parameters Parameters

$to_match

(null|array|string) (Optional)

Default value: null

$match_type

(null) (Optional)

Default value: 'int'

$recipes

(null) (Required)

$trigger_meta

(null) (Optional)

Default value: null

$trigger_code

(null) (Optional)

Default value: null


Top ↑

Return Return

(array)


Source Source

File: src/integrations/fluent-crm/helpers/fluent-crm-helpers.php

			'label'                    => $label,
			'input_type'               => $type,
			'supports_multiple_values' => $supports_multiple_values,
			'required'                 => true,
			'supports_tokens'          => $token,
			'is_ajax'                  => $is_ajax,
			'fill_values_in'           => $target_field,
			'endpoint'                 => $end_point,
			'options'                  => $options,
		);

		return $option;

	}

	/**
	 * @param null|array|string $to_match
	 * @param null              $match_type
	 * @param null              $recipes
	 * @param null              $trigger_meta
	 * @param null              $trigger_code
	 *
	 * @return array
	 */
	public function match_single_condition( $to_match = null, $match_type = 'int', $trigger_meta = null, $trigger_code = null ) {

		$recipe_ids = array();

		if (
			null === $to_match ||
			null === $trigger_meta ||
			null === $trigger_code
		) {
			// Sanity check
			return $recipe_ids;
		}

		$matched_recipe_ids = array();

		// Normalize $to_match as array
		if ( ! is_array( $to_match ) ) {
			$to_match = array( $to_match );
		}

		$recipes = Automator()->get->recipes_from_trigger_code( $trigger_code );

		foreach ( $recipes as $recipe ) {
			foreach ( $recipe['triggers'] as $trigger ) {
				if ( key_exists( $trigger_meta, $trigger['meta'] ) ) {

					$trigger_value = $trigger['meta'][ $trigger_meta ];

					foreach ( $to_match as $match ) {

						switch ( $match_type ) {
							case 'int':
								$trigger_value = (int) $trigger_value;
								$match         = (int) $match;
								break;
							case 'text':
								$trigger_value = (string) $trigger_value;
								$match         = (string) $match;
								break;
							case 'absint':
								$trigger_value = absint( $trigger_value );