Blog Post

Support for PHP 8.1 and 8.2 in plugins and WordPress

Last month, PHP 8.2 was released. PHP 7.4 has reached the End Of Life stage and is no longer officially updated or supported, with PHP 8.0 only getting securing fixes, making PHP 8.1 and PHP 8.2 the only officially supported and updated releases.

But the officially supported PHP versions are one thing, but the PHP versions used by the majority of hosting companies and what WordPress and WordPress plugins actually support are quite a different story. In the past month, I have done a lot of testing of both WordPress and my plugins with PHP 8.0, PHP 8.1, and PHP 8.2. I have also analyzed the usage statistics gathered by WordPress.org and Dev4Press.com.

PHP Usage Statistics

According to WordPress.org statistics, PHP 7.4 is the most popular version with 56%, PHP 8.0 is just under 10%, PHP 8.1 is around 4%, and PHP 8.2 is at 0%. Older PHP 7 versions have a total of around 23%, with PHP 5 versions still holding around 7%. This shows a slow addition rate for PHP 8.0, which is mostly caused by a lot of older WordPress plugins and themes having major issues with PHP 8.0 and newer versions.

Our statistics on Dev4Press.com show similar trends, with PHP 7.4 being the most popular version at 65%, PHP 8.0 being just under 14%, PHP 8.1 being around 8%, and PHP 8.2 again at 0%. Older PHP 7 versions have a total of around 13%, with PHP 5 versions under 2%. We have a smaller set of data available, but PHP 8 versions are still far from widespread adoption.

WordPress Compatibility

I have only tested the latest WordPress 6.1 because it is unrealistic that newer PHP versions will be properly supported in old versions of WordPress. So, WordPress 6.1 works fine with PHP 8.0, and I have not seen any errors logged during testing. But, with PHP 8.1, while WordPress did work correctly, error logs were getting filled by the deprecated warnings.

Most of these were related to the Requests library handling HTTP requests functionalities. One of these deprecated warnings affects the function for stripping tags from content, and it is for the preg_replace() core function and will pop up on most pages where the content is edited. Other than this, WordPress works fine with PHP 8.1. And the same happens with PHP 8.2 – mostly the same deprecated warnings and no other errors.

Some of the deprecated warnings with PHP 8.2 in WordPress core were captured with the DebugPress plugin.

I expect the next major WordPress version to get proper updates for these deprecated warnings in the latest PHP releases.

Dev4Press Plugins Compatibility

I have tested the latest versions of many Dev4Press plugins in the past few months, and so far, I have not found any issues with PHP 8.0. But, the testing with PHP 8.1 and PHP 8.2 did reveal several issues, some were deprecated warnings (similar to WordPress), and some were actual warnings, with no critical errors encountered. And I have started releasing updates to many plugins to fix these issues with PHP, and more such updates are expected in the coming months.

My development setups include all the latest builds for PHP 7.3 to PHP 8.2, and for this year, PHP 7.3 will remain supported for all Dev4Press plugins. The goal for 2023 is to have all plugins updated to work without any warnings or errors with PHP 8.2 and to prepare for the 8.3 coming out in late 2023.

WordPress Plugins and Themes

Well, this is very hard to test and gauge at this point. I did test third-party plugins and themes I use regularly, and most of them are working fine with PHP 8 versions, with some throwing the same deprecated warnings as WordPress.

But, when I attempted to randomly test many WordPress plugins from WordPress.org, even some very popular plugins, there were all sorts of issues, including critical errors, leaving the test website completely broken.

What about hosting companies?

As usual, it is hard to determine what is happening with a wide range of hosting companies and PHP support. I personally use SiteGround, and they offer all PHP versions from PHP 7.3 to PHP 8.2, with PHP 7.4 being the default right now. They do revisit that every year, so I expect that sometime this year, PHP 8.0 will be the default version.

I have access to several other hosting companies; in general, most offer at least PHP 8.0 or even higher. But, many companies still have PHP 5.6 as a default version, and from what I can see on websites like Reddit and Twitter, based on user experience, many hosting companies are still far from having newer PHP 8 versions available. PHP 7 adoption is much better. I suspect that a lot of hosting companies don’t want to invest a lot of time testing newer PHP versions, and a lot of them also want to avoid user issues with running old plugins on new PHP, so using PHP 7.3 or 7.4 is still the safest solution for most users and most hosting companies.

PHP after PHP 7

With PHP 7 officially no longer supported or updated, PHP 8 is the clear future, and the performance improvements, features improvements, and modernized syntax of new PHP is a very interesting proposition. I look forward to a better PHP experience in the coming years. For PHP 8 to grow in the WordPress ecosystem, plugin and theme developers need to increase the time dedicated to testing new PHP versions and fixing their plugins and themes to make them compatible with new PHP versions. This will push WordPress users and hosting companies to speed up the PHP 8 adoption. Hopefully, by the end of 2023, we will see much different statistics with PHP 8 versions starting to dominate global usage.

Let me know what you think about PHP 8 adoption, what is stopping you from doing that, how many plugins you use that have problems with new PHP versions, and what is your hosting company currently supporting.

Please wait...

About the author

Milan Petrovic
Milan Petrovic

Programmer since the age of 12 and WordPress developer since 2008 as freelancer and author of more than 200 plugins and more than 20 themes.

The Newsletter

Leave a Comment

GeneratePress - The perfect lightweight theme for your next project
SiteGround - Managed WordPress Hosting