WPJM_SUBMITJOB::match_condition( $terms, null $recipes = null, null $trigger_meta = null, null $trigger_code = null )


Parameters Parameters

$terms

(Required)

$recipes

(null) (Optional)

Default value: null

$trigger_meta

(null) (Optional)

Default value: null

$trigger_code

(null) (Optional)

Default value: null


Top ↑

Return Return

(array|bool)


Source Source

File: src/integrations/wp-job-manager/triggers/wpjm-submitjob.php

	public function match_condition( $terms, $recipes = null, $trigger_meta = null, $trigger_code = null ) {

		if ( null === $recipes ) {
			return false;
		}

		$recipe_ids     = array();
		$entry_to_match = array();
		if ( empty( $terms ) ) {
			return false;
		}
		foreach ( $terms as $term ) {
			$entry_to_match[] = $term->term_id;
		}

		foreach ( $recipes as $recipe ) {
			foreach ( $recipe['triggers'] as $trigger ) {
				if ( key_exists( $trigger_meta, $trigger['meta'] ) && ( in_array( (int) $trigger['meta'][ $trigger_meta ], $entry_to_match, true ) || $trigger['meta'][ $trigger_meta ] === "-1" ) ) {
					$recipe_ids[ $recipe['ID'] ] = $recipe['ID'];
					break;
				}
			}
		}

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

		return false;
	}