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
ablocks / includes / frontend / dynamic-content / interpreters / shortcode.php

shortcode.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.13.0, at includes/frontend/dynamic-content/interpreters/shortcode.php

29 lines 967 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Frontend\DynamicContent\Interpreters;
3
4 use ABlocks\Helper;
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8 class Shortcode extends Abstracts\Interpreter {
9 protected string $shortcode;
10 protected string $pre;
11 protected string $post;
12 protected string $default;
13
14 public function __construct( string $name, array $setting, bool $is_richtext = false ) {
15 parent::__construct( $name, $setting, $is_richtext );
16 $this->shortcode = strval( $this->setting[0] ?? '' );
17 $this->pre = strval( $this->setting[3] ?? '' );
18 $this->post = strval( $this->setting[4] ?? '' );
19 $this->default = strval( $this->setting[5] ?? '' );
20 }
21 public function content() : string {
22 $this->content = do_shortcode( $this->shortcode );
23 return $this->pre . ( $this->content === '' ? $this->default : $this->content ) . $this->post;
24 }
25 public function req_param_value( array $params ) : string {
26 return sanitize_text_field( $params[ $this->param ] ?? '' );
27 }
28 }
29