Action_Parser::maybe_parse_tokens( $user_id,  $action_data,  $recipe_id,  $args )


Parameters Parameters

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)

$args

(Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/core/lib/recipe-parts/actions/trait-action-parser.php

	public function maybe_parse_tokens( $user_id, $action_data, $recipe_id, $args ) {
		if ( ! array_key_exists( 'meta', $action_data ) ) {
			return $this->get_parsed();
		}
		$metas = $action_data['meta'];
		if ( empty( $metas ) ) {
			return $this->get_parsed();
		}
		$this->pre_parse();
		foreach ( $metas as $meta_key => $meta_value ) {
			if ( ! $this->is_valid_token( $meta_key, $meta_value ) ) {
				$parsed = Automator()->parse->text( $meta_value, $recipe_id, $user_id, $args );
				$this->set_parsed( $meta_key, $this->should_wpautop( $parsed ) );
				continue;
			}
			$parsed     = Automator()->parse->text( $meta_value, $recipe_id, $user_id, $args );
			$token_args = array(
				'user_id'     => $user_id,
				'action_data' => $action_data,
				'recipe_id'   => $recipe_id,
				'args'        => $args,
			);
			$parsed = apply_filters( 'automator_pre_token_parsed', $parsed, $meta_key, $token_args );
			if ( $this->is_do_shortcode() ) {
				$parsed = do_shortcode( $parsed );
			}
			$parsed = apply_filters( 'automator_post_token_parsed', $this->should_wpautop( $parsed ), $meta_key, $token_args );
			$this->set_parsed( $meta_key, $parsed );
		}
		return $this->get_parsed();
	}