Automator_Input_Parser::automator_maybe_parse_postmeta_token( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)

$replace_args

(Required)


Top ↑

Return Return

(mixed|string)


Source Source

File: src/core/lib/utilities/class-automator-input-parser.php

	public function automator_maybe_parse_postmeta_token( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( ! in_array( 'POSTMETA', $pieces, true ) ) {
			return $value;
		}
		$pieces  = $this->parse_inner_token( $pieces, $replace_args );
		$post_id = isset( $pieces[1] ) ? absint( $pieces[1] ) : null;
		if ( null === $post_id ) {
			return $value;
		}
		$meta_key = sanitize_text_field( $pieces[2] );
		$value    = get_post_meta( $post_id, $meta_key, true );
		if ( is_array( $value ) ) {
			$value = join( ', ', $value );
		}

		return apply_filters(
			'automator_postmeta_token_parsed',
			$value,
			$post_id,
			$meta_key,
			array(
				'value'        => $value,
				'pieces'       => $pieces,
				'recipe_id'    => $recipe_id,
				'trigger_data' => $trigger_data,
				'user_id'      => $user_id,
				'replace_args' => $replace_args,
			)
		);
	}