# ablocks/2.9.1/includes/frontend/dynamic-content/interpreter.php

aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder &amp; Animation Builder, version 2.9.1. 55 lines.

- Page: https://pluginprobe.com/plugins/ablocks/2.9.1/code/includes/frontend/dynamic-content/interpreter.php
- Raw: https://pluginprobe.com/plugins/ablocks/2.9.1/raw/includes/frontend/dynamic-content/interpreter.php
- Modified: 2025-04-22T12:59:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ablocks/2.9.1/code/includes/frontend/dynamic-content/interpreter.php#L10-L20`.

```php
<?php
namespace ABlocks\Frontend\DynamicContent;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
class Interpreter {

	protected array $interpreters = [
		'post-type' => Interpreters\PostType::class,
		'current'   => Interpreters\CurrentPost::class,
		'current-date-time' => Interpreters\CurrentDateTime::class,
		'site-title'   => Interpreters\SiteTitle::class,
		'site-tagline' => Interpreters\SiteTagline::class,
		'user-info'    => Interpreters\UserInfo::class,
		'request-parameter' => Interpreters\RequestParams::class,
		'shortcode' => Interpreters\Shortcode::class,
		'link'  => Interpreters\Link::class,
		'image' => Interpreters\Image::class,
	];
	protected string $content;
	public function __construct( string $content ) {
		$this->content = $content;
		$this->parse();// exit;
	}
	public function parse() : void {
		$this->content = preg_replace_callback(
			'~ablocks_dc:(.+?):ablocks_dc|<span\s+(?=[^>]*\bclass=["\']ablocks-richtext-dynamic-content["\'])(?=[^>]*\bdata-source=["\']([^"\']+)["\'])(?=[^>]*\bdata-field=["\']([^"\']+)["\'])[^>]*>(.*?)<\/span>~ims',
			[ $this, 'apply_changes' ],
			$this->content
		);
	}
	public function apply_changes( array $matches ) : string {
		return is_null( $ins = ( new ArgumentParser( ...$this->filter( $matches ), ...[ $this->interpreters ] ) )->interpret() ) ? '' : $ins->content();
	}

	public function filter( array $matches ) : array {
		$is_richtext = false;
		array_shift( $matches );
		if ( count( $matches ) > 2 ) {
			array_shift( $matches );
			$is_richtext = true;
		}
		return [
			implode( '|', $matches ),
			$is_richtext
		];
	}

	public static function init( string $content ) : string {
		$ins = new self( $content );
		return $ins->content;
	}
}

```
