PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 1.2.4
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v1.2.4
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / app / Helpers / Helper.php

Helper.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 1.2.4, at app/Helpers/Helper.php

63 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Helpers;
4
5 use FluentForm\Framework\Helpers\ArrayHelper;
6
7 class Helper
8 {
9 /**
10 * Sanitize form inputs recursively.
11 *
12 * @param $input
13 *
14 * @return string $input
15 */
16 public static function sanitizer($input, $attribute = null, $fields = [])
17 {
18 if (is_string($input)) {
19 if (ArrayHelper::get($fields, $attribute.'.element') === 'textarea') {
20 $input = sanitize_textarea_field($input);
21 } else {
22 $input = sanitize_text_field($input);
23 }
24 } elseif (is_array($input)) {
25 foreach ($input as $key => &$value) {
26 $attribute = $attribute ? $attribute.'['.$key.']' : $key;
27
28 $value = Helper::sanitizer($value, $attribute, $fields);
29
30 $attribute = null;
31 }
32 }
33
34 return $input;
35 }
36
37 public static function makeMenuUrl($page = 'fluent_forms_settings', $component = null)
38 {
39 $baseUrl = admin_url('admin.php?page='.$page);
40
41 return $component ? $baseUrl.'#'.ArrayHelper::get($component, 'hash', '') : $baseUrl;
42 }
43
44 public static function getHtmlElementClass($value1, $value2, $class = 'active', $default = '')
45 {
46 return $value1 === $value2 ? $class : $default;
47 }
48
49 /**
50 * Determines if the given string is a valid json.
51 *
52 * @param $string
53 *
54 * @return bool
55 */
56 public static function isJson($string)
57 {
58 json_decode($string);
59
60
61 return json_last_error() === JSON_ERROR_NONE;
62 }
63 }