WP_SUBMITCOMMENT::match_condition( array $post_id,  $post_type, array $recipes = null, string $trigger_meta = null, string $trigger_code = null )

Matching Form id because its not an integer.


Parameters Parameters

$post_id

(Required) .

$recipes

(Optional) .

Default value: null

$trigger_meta

(Optional) .

Default value: null

$trigger_code

(Optional) .

Default value: null


Top ↑

Return Return

(array|bool)


Source Source

File: src/integrations/wp/triggers/wp-submitcomment.php

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

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

		$recipe_ids      = array();
		$match_post_id   = $post_id;
		$match_post_type = $post_type;
		foreach ( $recipes as $recipe ) {
			foreach ( $recipe['triggers'] as $trigger ) {
				if ( ! key_exists( 'WPPOSTTYPES', $trigger['meta'] ) ) {
					if ( key_exists( $trigger_meta, $trigger['meta'] ) && ( (string) $trigger['meta'][ $trigger_meta ] === (string) $match_post_id || '-1' === (string) $trigger['meta'][ $trigger_meta ] ) ) {
						$recipe_ids[ $recipe['ID'] ] = $recipe['ID'];
					}
				} else {
					if ( key_exists( $trigger_meta, $trigger['meta'] )
					     && ( (string) $trigger['meta'][ $trigger_meta ] === (string) $match_post_id || '-1' === (string) $trigger['meta'][ $trigger_meta ] )
					     && ( (string) $trigger['meta']['WPPOSTTYPES'] === (string) $match_post_type || '-1' === (string) $trigger['meta']['WPPOSTTYPES'] )
					) {
						$recipe_ids[ $recipe['ID'] ] = $recipe['ID'];
					}
				}
			}
		}

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

		return false;
	}