Important: How to Fix My FlexiTheme After Updating to WordPress 5.1

Last night, I was doing a final round of support before bed, and noticed there was a ticket about an issue with WordPress 5.1.

Then some more came in. I asked for login info to take a look and starting checking locally while I waited.

Then more tickets came in and they kept on coming.

WordPress 5.1 Fatal Error

There was definitely something wrong and it was in many of our themes. We quickly debugged it, found the cause, and started working on a fix.

We found out that the issue is in all our themes… and since we have over 2,200 WordPress themes… that’s a lot of themes to update!

Thanks to our brilliant developer, we created several scripts to fix the issues across all themes and to upload all the themes on the site

The Issue

Updating to WordPress 5.1 caused the front-end of the website to crash, but the backend works fine (except for our theme customizer).

For some sites, there’s a blank white page on the front-end.

For other sites, there’s a fatal error on the front-end:

Fatal error: Call to a member function hook() on null in wp-content/themes/ [name of theme] /header.php on line 8

Background Information

As one user mentioned, the theme had been working wonderfully for years – until yesterday.

The reason is that WordPress 5.1 introduced a new variable in wp-settings.php called $themes without namespacing it.

That conflicts with the $theme global that we use in our themes, along with themes of other developers.

We’ve reported the issue to WordPress’ team. (They do a wonderful job with the WordPress core and we’re happy with WordPress nonetheless)

We worked around it by namespacing our variable so that there’s no conflict and that the issue doesn’t happen again. Based on an old guideline for namespacing, this wasn’t required, but we thought it was best for an immediate and future proof solution.

The Solution

Update to the latest version of your theme. If you’re using a Pro version, be sure you update to the latest Pro version.

How to Prevent This Issue from Happening

Update to the latest WordPress theme before upgrading to WordPress 5.1.

If you already have the issue, don’t worry. Follow the instructions below to fix it quickly.

How to Update

Important! Before applying these instructions:

  1. Check the theme version you have installed in your site. (You can find it in your “wp-admin / Appearance / Themes”)
  2. Check the current version of the theme from its homepage
  3. If the current version of theme is more than 0.1 higher than your installed version: You should check the theme’s changelog and apply any previous upgrade instructions (if there are any)

Then, follow the below instructions:

  1. Download attached file by right clicking this link and “Save as”
  2. Rename the file to something someone else won’t be able to guess, and change it to a .php file (i.e. remove the .txt from the name and add .php)
  3. Upload it to the root directory of your WordPress theme, so wp-content/themes/[name of theme] . If you’re using a child theme, be sure to do it in the child theme as well, including the steps below.
  4. Go to your example.org/wp-content/themes/[name of theme]/[name of your file from step 2.php]
  5. You should see a success message. Check your site and everything should work.
  6. Delete the file from the server
  7. Edit your style.css and update the version number, adding 0.1 to the existing number. So if it’s 1.1, change it to 1.2.
  8. That’s it!

Note, the above script will preserve all customizations that you’ve made to our themes. Enjoy!

Pro tip: In theory, the above script should work for themes from other companies that are experiencing the same issue. So if you found this post from Google, talk to your developer about it or give it a try in a test environment first.

Alternative: Downgrade WordPress to 5.0

If you want a quick workaround to buy you some time, downgrade to WordPress 5.0 using this easy-to-use downgrade plugin.

Then you can update the theme using the above instructions, and finally re-update to WordPress 5.1.

Need help?

If you have any questions, contact us and we’ll reply quickly.

If you’re a Pro member and want us to do the upgrade for you, please send us wp-admin and cPanel login through our secure contact form.

We’re on standby this weekend to help as needed.