Copy_Recipe_Parts::replace_action_token_ids( $content )


Parameters Parameters

$content

(Required)


Top ↑

Return Return

(array|mixed|string|string[]|null)


Source Source

File: src/core/admin/class-copy-recipe-parts.php

	public function replace_action_token_ids( $content ) {
		// Loop thru multiple actions and update token's action ID based on that.
		foreach ( $this->action_tokens as $prev_id => $new_id ) {
			// Sanity check
			if ( is_array( $prev_id ) || is_array( $new_id ) ) {
				continue;
			}
			// check if content contains a replaceable token by previous ID
			if ( preg_match( '/{{(ACTION_(FIELD|META)\:)' . $prev_id . '\:\w.+?}}/', $content ) ) {
				$content = preg_replace( '/{{ACTION_(FIELD|META)\:' . $prev_id . ':/', '{{ACTION_$1\:' . $new_id . ':', $content );
			}
		}
		return $content;
	}