[SOLVED] Uncaught Error: Call to undefined function set_magic_quotes_runtime() when importing RSS .xml files into WordPress

October 2, 2019

If your server environment is on PHP 7.0 or above, and you use the core WordPress RSS Importer tool from your dashboard (WP-Admin -> Tools -> Import -> RSS/Run Importer ) you may run into debug output showing a line including set_magic_quotes_runtime or simply just a default generic error like this:

The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.

If you check your server error logs, you'll likely see an error pertaining to set_magic_quotes_runtime like this:

PHP Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime()

The set_magic_quotes_runtime() function was removed from PHP 7+ (source) so you'll need to do some trickery to make it work. Thankfully, the fix should be as simple as copying the following snippet to your theme's functions.php file (anywhere after the opening <?php tag):

if (!function_exists('set_magic_quotes_runtime')) {
     function set_magic_quotes_runtime($new_setting) {
         return true;
     }
 }

One that's added, try the import again. You should be all set!