PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / compatibility / jet-engine / macros / base-field-context-macro.php

base-field-context-macro.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at compatibility/jet-engine/macros/base-field-context-macro.php

59 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shared helpers for JetEngine macros that read JetFormBuilder field values.
4 *
5 * @package JFB_Compatibility\Jet_Engine\Macros
6 */
7
8 namespace JFB_Compatibility\Jet_Engine\Macros;
9
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 abstract class Base_Field_Context_Macro extends \Jet_Engine_Base_Macros {
15
16 protected function get_context_value( string $field_name ) {
17 $request_key = 'jfb_update_related_' . $field_name;
18
19 if (
20 isset( $GLOBALS['jfb_generator_context'] ) &&
21 is_array( $GLOBALS['jfb_generator_context'] ) &&
22 array_key_exists( $field_name, $GLOBALS['jfb_generator_context'] )
23 ) {
24 return $this->sanitize_value( $GLOBALS['jfb_generator_context'][ $field_name ] );
25 }
26
27 if ( isset( $_REQUEST[ $request_key ] ) ) {
28 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
29 return $this->sanitize_value( wp_unslash( $_REQUEST[ $request_key ] ) );
30 }
31
32 if ( isset( $GLOBALS[ $request_key ] ) ) {
33 return $this->sanitize_value( $GLOBALS[ $request_key ] );
34 }
35
36 if ( function_exists( 'jet_fb_context' ) ) {
37 $request_data = jet_fb_context()->resolve_request();
38
39 if ( isset( $request_data[ $field_name ] ) ) {
40 return $this->sanitize_value( $request_data[ $field_name ] );
41 }
42 }
43
44 return '';
45 }
46
47 protected function sanitize_value( $value ) {
48 if ( is_array( $value ) ) {
49 return $value;
50 }
51
52 if ( is_numeric( $value ) ) {
53 return $value;
54 }
55
56 return sanitize_text_field( $value );
57 }
58 }
59