Fixing MyFontsWebfontsKit’s Fatal Uncaught Error Using $this Object Outside of Context

Oh, the sheer panic of loading your WordPress website to discover that your website has encountered a fatal error.

Sometimes it’s the white screen of death without errors. Other times it’s the white screen of death with a message about a fatal error email sent to your site administrator.

In my most recent case, it was the latter. While it’s good on one hand to know a fatal error has occurred, such messaging is utterly useless if you’re not the administrator of the website. And this is the case of today’s tutorial.

I received a frantic text message from a friend stating their WordPress website was loading, but they were unable to login to the backend. I thought it not to be possible at first glance of the message because if there is a WordPress error of any sort, especially a fatal error, then both front and back ends of WordPress are often not accessible.

But sure enough, my friend’s website loaded as she indicated. I attempted to access the WordPress dashboard and was created by the white screen of death with a message about a fatal error email sent to the site administrator, which is not me.

So, what fatal error could have caused this message to display? When not an administrator of the web hosting account, one of the first things to do is gain FTP access to the website, which fortunately I had.

Having FTP access to the root folder of the website, I was able to access the error log file to discover the explicit details about the fatal error. I simply loaded the WordPress admin in a web browser, noted the time of day in which I loaded the page, and then found the corresponding day and time in the error file.

If your web server is not hosted in the same time zone, then figure out in what time zone your server is hosted and do a bit of time conversion math.

Nevertheless, I discovered the error log file containing the following error details at its conclusion:

For most WordPress website owners, that code is a bunch of gibberish that wrecked a good thing going for their website. The fatal-error culprit in this case is the MyFontsWebfontsKit plugin, which is used to provide an elegant display of fonts on my friend’s website.

In short, there is a method in line 28 of the mf-options.inc file that references the $this object. However, there is not a global $this object initiated — not one that I could easily find. I attempted coding around it, commenting out the variable that uses it, and setting a global $this with no success.

Truth be told, MyFonts.com, the authors My Fonts plugin, should provide a plugin update to address this critical error.

But in the meantime and in-between time, I discovered an alternative plugin, Use Any Font, that does the trick and is lighter weight than the MyFontsWebfontsKit plugin.

The Use Any Font plugin for WordPress is a simple and easy tool to upload any custom fonts you wish without needing in-depth CSS knowledge. It’s good to have a base knowledge of CSS though. This will make for an easier time using it.

So, move forward and install the Use Any Font plugin. As for fonts, locate MyFontsWebfontsKit font files your website uses in the web fonts folder of the plugin. In this case, the path to my friend’s font files for their website is the following:

/home1/webx/public_html/web1/wp-content/plugins/MyFontsWebfontsKit/webfonts/

For example, listed below are the .eot, .tff, .woff, and .woff2 files for my friend’s website:

  • 32FC30_0_0.eot
  • 32FC30_0_0.tff
  • 32FC30_0_0.woff
  • 32FC30_0_0.woff2

FTPing into the webserver using Filezilla, I downloaded the files and then uploaded the files via Use Any Font Plugin.

To use the Use Any Font plugin, be sure to create either a FREE or paid API KEY in the WordPress Admin plugin settings.

In a simple and intuitive sign, Use Any Font offers the ability to apply fonts at a global site level as well as assigning HTML elements and aspects of one’s website.

For instance, a certain font could be used for Header tags or per Header tag, while a completely different font could be used for body, site, menu, and other HTML elements.

All in all, the Use Any Font plugin is a lifesaver and a great alternative fix and solution to remedy the MyFontsWebfontsKit plugin’s fatal error about the out of context usage fo the $this object.

Let me know if you have any questions, comments, or encounter any additional technical challenges. Enjoy!

Share:
Written by Alvin Brown
He's an experienced and passionate serial entrepreneur, founder and publisher of Kickstart Commerce. Alvin possesses a great love for startups dominating their market using profitable digital strategies for greater commerce.