PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/frontend/dynamic-content/argument-parser.php +33 -0 2.7.62.13.0 View file →
@@ -1,0 +1,33 @@
1 +<?php
2 +namespace ABlocks\Frontend\DynamicContent;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +class ArgumentParser {
8 +
9 + protected array $args;
10 + protected array $interpreters;
11 + protected string $arg_str;
12 + protected bool $is_richtext;
13 + protected $context;
14 + public function __construct( string $arg_str, bool $is_richtext, array $interpreters, array $context = [] ) {
15 + $this->arg_str = $arg_str;
16 + $this->is_richtext = $is_richtext;
17 + $this->interpreters = $interpreters;
18 + $this->context = $context;
19 + }
20 + public function interpret() : ?Interpreters\Abstracts\Interpreter {
21 + $setting = explode( '|', $this->arg_str );
22 + $action_name = $setting[0];
23 + array_shift( $setting );
24 +
25 + if ( ! empty( $class = $this->interpreters[ $action_name ] ?? '' ) &&
26 + class_exists( $class ) &&
27 + ( $ins = new $class( $action_name, $setting, $this->is_richtext, $this->context ) ) instanceof Interpreters\Abstracts\Interpreter
28 + ) {
29 + return $ins;
30 + }
31 + return null;
32 + }
33 +}