WP Website fatal error when Cloudlfare is On

I am getting this fatal error when turning on cloudlfare. Otherwise WP site works normal.

Fatal error: Uncaught Error: Call to undefined function mb_detect_encoding() in /home/zadarb/public_html/wp-content/plugins/wp-optimize/minify/class-wp-optimize-minify-functions.php:426 Stack trace: #0 /home/zadarb/public_html/wp-content/plugins/wp-optimize/minify/class-wp-optimize-minify-functions.php(625): WP_Optimize_Minify_Functions::get_css(‘https://fonts.g…’, ‘/* cyrillic-ext…’, true) #1 /home/zadarb/public_html/wp-content/plugins/wp-optimize/minify/class-wp-optimize-minify-front-end.php(621): WP_Optimize_Minify_Functions::download_and_minify(‘https://fonts.g…’, ‘’, true, ‘css’, ‘’) #2 /home/zadarb/public_html/wp-includes/class-wp-hook.php(324): WP_Optimize_Minify_Front_End->process_header_css(‘’) #3 /home/zadarb/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(‘’, Array) #4 /home/zadarb/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /home/zadarb/public_html/wp-includes/functions.wp-styles.php(57): do_action(‘wp_print_styles’) #6 /home/zadarb/public_html/wp-includes/class-wp-hook.php(324): wp_print_styles(false) #7 /home/zadarb/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #8 /home/zadarb/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #9 /home/zadarb/public_html/wp-includes/general-template.php(3050): do_action(‘wp_head’) #10 /home/zadarb/public_html/wp-content/themes/betheme/header.php(21): wp_head() #11 /home/zadarb/public_html/wp-includes/template.php(810): require_once(‘/home/zadarb/pu…’) #12 /home/zadarb/public_html/wp-includes/template.php(745): load_template(‘/home/zadarb/pu…’, true, Array) #13 /home/zadarb/public_html/wp-includes/general-template.php(48): locate_template(Array, true, true, Array) #14 /home/zadarb/public_html/wp-content/themes/betheme/page.php(10): get_header() #15 /home/zadarb/public_html/wp-includes/template-loader.php(106): include(‘/home/zadarb/pu…’) #16 /home/zadarb/public_html/wp-blog-header.php(19): require_once(‘/home/zadarb/pu…’) #17 /home/zadarb/public_html/index.php(17): require(‘/home/zadarb/pu…’) #18 {main} thrown in /home/zadarb/public_html/wp-content/plugins/wp-optimize/minify/class-wp-optimize-minify-functions.php on line 426 There has been a critical error on this website

Has anyone had a similar experience?

Thanks a lot.

1 Like

Hi there,

Looking at your error log, this seems to be related to WP Optimize plugin when calling the function mb_detect_encoding().

This would point to mbstring PHP extension not being enabled on your server side.
Could you please double-check with your hosting provider if the mentioned PHP extension is enabled or not?
Here’s something that might help: How to enable MBstring extension in CPanel or WHM VPS servers? - H2S Media

But to be clear, this does not seem Cloudflare related. If you are not able to solve it, you can perhaps disable that plugin and see if it solves the issue. If it does, since Cloudflare has its own minification settings, you can then decide either to leave it disabled (with the option to enable minification at the edge), or to debug the issue with the WP Optimize plugin, perhaps by contacting the developer or requesting assistance.

Take care.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.