@@ -160,7 +160,7 @@ function menu( $items, $default = null, $title = 'Choose an item' ) {
160160 * @return int Numeric value that represents the string's length
161161 */
162162function safe_strlen ( $ str ) {
163- if ( function_exists ( 'mb_strlen ' ) ) {
163+ if ( function_exists ( 'mb_strlen ' ) && function_exists ( ' mb_detect_encoding ' ) ) {
164164 $ length = mb_strlen ( $ str , mb_detect_encoding ( $ str ) );
165165 } else {
166166 // iconv will return PHP notice if non-ascii characters are present in input string
@@ -182,7 +182,7 @@ function safe_strlen( $str ) {
182182 * @return string Substring of string specified by start and length parameters
183183 */
184184function safe_substr ( $ str , $ start , $ length = false ) {
185- if ( function_exists ( 'mb_substr ' ) ) {
185+ if ( function_exists ( 'mb_substr ' ) && function_exists ( ' mb_detect_encoding ' ) ) {
186186 $ substr = mb_substr ( $ str , $ start , $ length , mb_detect_encoding ( $ str ) );
187187 } else {
188188 // iconv will return PHP notice if non-ascii characters are present in input string
@@ -204,7 +204,7 @@ function safe_substr( $str, $start, $length = false ) {
204204function safe_str_pad ( $ string , $ length ) {
205205 // Hebrew vowel characters
206206 $ cleaned_string = preg_replace ( '#[\x{591}-\x{5C7}]+#u ' , '' , Colors::decolorize ( $ string ) );
207- if ( function_exists ( 'mb_strwidth ' ) ) {
207+ if ( function_exists ( 'mb_strwidth ' ) && function_exists ( ' mb_detect_encoding ' ) ) {
208208 $ real_length = mb_strwidth ( $ cleaned_string , mb_detect_encoding ( $ string ) );
209209 } else {
210210 $ real_length = safe_strlen ( $ cleaned_string );
0 commit comments