Wp_Post_Tokens::parse_wp_post_tokens( $value,  $pieces,  $recipe_id,  $trigger_data, int $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(int) (Required)

$replace_args

(Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/wp/tokens/wp-post-tokens.php

	public function parse_wp_post_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id = 0, $replace_args ) {
		$tokens = [
			'WPTAXONOMIES',
			'SPECIFICTAXONOMY',
			'POSTSTATUSUPDATED',
			'POSTAUTHORFN',
			'POSTAUTHORLN',
			'POSTAUTHORDN',
			'POSTAUTHOREMAIL',
			'POSTCONTENT',
			'POSTURL',
			'POSTID',
			'POSTTITLE',
			'WPTAXONOMYTERM',
			'WPPOSTTYPES',
			'POSTCOMMENTCONTENT',
			'POSTCOMMENTDATE',
			'POSTCOMMENTEREMAIL',
			'POSTCOMMENTERNAME',
			'POSTCOMMENTSTATUS'
		];

		if ( $pieces && isset( $pieces[2] ) ) {
			$meta_field = $pieces[2];

			if ( ! empty( $meta_field ) && in_array( $meta_field, $tokens ) ) {
				if ( $trigger_data ) {
					foreach ( $trigger_data as $trigger ) {
						switch ( $meta_field ) {
							case 'WPTAXONOMIES':
								$value = $trigger['meta']['WPTAXONOMIES_readable'];
								break;
							case 'SPECIFICTAXONOMY':
								$value = $trigger['meta']['SPECIFICTAXONOMY_readable'];
								break;
							case 'POSTSTATUSUPDATED':
								$value = $trigger['meta']['POSTSTATUSUPDATED_readable'];
								break;
							default:
								global $wpdb;
								$trigger_id = $trigger['ID'];
								$meta_value = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->prefix}uap_trigger_log_meta WHERE meta_key LIKE '%{$meta_field}%' AND automator_trigger_id = {$trigger_id} ORDER BY ID DESC LIMIT 0,1" );
								if ( ! empty( $meta_value ) ) {
									$value = maybe_unserialize( $meta_value );
								}
						}
					}
				}
			}
		}

		return $value;
	}