PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
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 / request-params.php

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

48 lines 1.4 KB
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 RequestParams extends Abstracts\Interpreter {
9 protected string $field;
10 protected string $param;
11 protected string $pre;
12 protected string $post;
13 protected string $default;
14
15 public function __construct( string $name, array $setting, bool $is_richtext = false ) {
16 parent::__construct( $name, $setting, $is_richtext );
17 $this->field = strtolower( strval( $this->setting[0] ?? 'get' ) );
18 $this->param = strval( $this->setting[1] ?? '' );
19 $this->pre = strval( $this->setting[3] ?? '' );
20 $this->post = strval( $this->setting[4] ?? '' );
21 $this->default = strval( $this->setting[5] ?? '' );
22 $this->field = empty( $this->field ) ? 'get' : $this->field;
23 }
24 public function content() : string {
25
26 switch ( $this->field ) {
27 case 'get':
28 $this->content = $this->req_param_value( $_GET );
29 break;
30
31 case 'post':
32 $this->content = $this->req_param_value( $_POST );
33 break;
34
35 case 'query var':
36 $this->content = get_query_var( $this->param, '' );
37 break;
38
39 default:
40 $this->content = '';
41 }
42 return $this->pre . ( $this->content === '' ? $this->default : $this->content ) . $this->post;
43 }
44 public function req_param_value( array $params ) : string {
45 return sanitize_text_field( $params[ $this->param ] ?? '' );
46 }
47 }
48