PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.12
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.12
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 / boot / MbstringFallback.php

MbstringFallback.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.12, at boot/MbstringFallback.php

124 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plain-PHP fallbacks for mb_* functions when mbstring extension is missing.
5 *
6 * These handle ASCII correctly, which is sufficient for the framework's
7 * internal use (route matching, snake/camel case, validator attribute parsing).
8 *
9 * WordPress already polyfills mb_strlen and mb_substr via wp-includes/compat.php.
10 * This file covers the remaining functions the framework and plugin use.
11 *
12 * When mbstring IS loaded, this file does nothing.
13 */
14
15 if (extension_loaded('mbstring')) {
16 return;
17 }
18
19 if (!defined('MB_CASE_UPPER')) {
20 define('MB_CASE_UPPER', 0);
21 }
22
23 if (!defined('MB_CASE_LOWER')) {
24 define('MB_CASE_LOWER', 1);
25 }
26
27 if (!defined('MB_CASE_TITLE')) {
28 define('MB_CASE_TITLE', 2);
29 }
30
31 if (!function_exists('mb_strlen')) {
32 function mb_strlen($string, $encoding = null)
33 {
34 return strlen($string);
35 }
36 }
37
38 if (!function_exists('mb_substr')) {
39 function mb_substr($string, $start, $length = null, $encoding = null)
40 {
41 return $length === null ? substr($string, $start) : substr($string, $start, $length);
42 }
43 }
44
45 if (!function_exists('mb_strtolower')) {
46 function mb_strtolower($string, $encoding = null)
47 {
48 return strtolower($string);
49 }
50 }
51
52 if (!function_exists('mb_strtoupper')) {
53 function mb_strtoupper($string, $encoding = null)
54 {
55 return strtoupper($string);
56 }
57 }
58
59 if (!function_exists('mb_strpos')) {
60 function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
61 {
62 return strpos($haystack, $needle, $offset);
63 }
64 }
65
66 if (!function_exists('mb_strrpos')) {
67 function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
68 {
69 return strrpos($haystack, $needle, $offset);
70 }
71 }
72
73 if (!function_exists('mb_strwidth')) {
74 function mb_strwidth($string, $encoding = null)
75 {
76 return strlen($string);
77 }
78 }
79
80 if (!function_exists('mb_strimwidth')) {
81 function mb_strimwidth($string, $start, $width, $trimmarker = '', $encoding = null)
82 {
83 $string = substr($string, $start);
84
85 if (strlen($string) <= $width) {
86 return $string;
87 }
88
89 $markerLen = strlen($trimmarker);
90
91 return substr($string, 0, $width - $markerLen) . $trimmarker;
92 }
93 }
94
95 if (!function_exists('mb_convert_case')) {
96 function mb_convert_case($string, $mode, $encoding = null)
97 {
98 switch ($mode) {
99 case MB_CASE_UPPER:
100 return strtoupper($string);
101 case MB_CASE_LOWER:
102 return strtolower($string);
103 case MB_CASE_TITLE:
104 return ucwords(strtolower($string));
105 default:
106 return $string;
107 }
108 }
109 }
110
111 if (!function_exists('mb_str_split')) {
112 function mb_str_split($string, $length = 1, $encoding = null)
113 {
114 return str_split($string, $length);
115 }
116 }
117
118 if (!function_exists('mb_split')) {
119 function mb_split($pattern, $string, $limit = -1)
120 {
121 return preg_split('/' . $pattern . '/u', $string, $limit);
122 }
123 }
124