WordPress and PHP 8.2: what changes for plugins and themes

By CompatNav · Published · Last reviewed · 5 min read

Short answer

WordPress 6.1 and later work with PHP 8.2; your plugins and theme decide whether your site does. Of the PHP 8.2 changes you’re most likely to meet in plugins and themes, almost all only log deprecation notices, and the code keeps working: dynamic properties, "${var}" in strings, utf8_encode(), "self::method" callbacks. A few functions changed their results silently. PHP 8.2 gets security fixes until 31 December 2026, so if your site is on it, plan the next step now.

Is WordPress ready for PHP 8.2?

PHP 8.2 was released on 8 December 2022. Its active support ended on 31 December 2024; it gets security fixes until 31 December 2026 (php.net).

The WordPress core team’s compatibility page lists WordPress 6.1 and later as compatible with PHP 8.2. That covers WordPress itself; the changes below concern the code of your plugins and theme.

Already running PHP 8.2? Then the more urgent question is the next version: what the end of security fixes means and which version to choose is in PHP 8.2 reaches end of life.

The short version

The PHP 8.2 changes you’re most likely to meet in plugins and themes. php.net lists the full set of deprecated features and backward incompatible changes.

What changes in PHP 8.2What happensKind
Properties created on the fly (dynamic properties)Deprecation notice, code keeps workingNotice
"${var}" and "${expr}" inside textDeprecation notice, code keeps workingNotice
utf8_encode() and utf8_decode()Deprecation notice, code keeps workingNotice
Callbacks written as "self::method" or "parent::method"Deprecation notice, code keeps workingNotice
HTML-ENTITIES, QPrint, Base64, Uuencode in mbstring functionsDeprecation notice, code keeps workingNotice
strtolower(), ucfirst() and similarNo longer follow the server’s localeSilent change

None of these stops a page. If your site comes from PHP 7.4, the bigger step is the one to PHP 8.0, which removed functions and syntax outright: see moving from PHP 7.4 to PHP 8.

Dynamic properties

The PHP 8.2 notice you’ll see most in WordPress logs. php.net: “The creation of dynamic properties is deprecated, unless the class opts in by using the #[\AllowDynamicProperties] attribute.” (php.net) What it means, why it isn’t urgent and who fixes it has its own guide: “Creation of dynamic property … is deprecated”.

"${var}" in text

Older code sometimes puts variables into text as "${name}". PHP 8.2 still runs it and adds a notice:

wp-content/plugins/simple-greeting/simple-greeting.php

<?php
$name = 'Anna';
echo "Hello ${name}!\n";

Output on PHP 8.1.34

Hello Anna!

Output on PHP 8.2.34

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/wp-content/plugins/simple-greeting/simple-greeting.php on line 3
Hello Anna!

php.net: “The “${var}” and “${expr}” style of string interpolation is deprecated.” (php.net) The fix is a two-character change for whoever maintains the code; both wordings of the notice and the fixes are in “Using ${var} in strings is deprecated”.

utf8_encode() and utf8_decode()

Import and export plugins use these to convert between UTF-8 and the older ISO-8859-1 character set. PHP 8.2 marks both: “utf8_encode() and utf8_decode() have been deprecated.” (php.net)

wp-content/plugins/old-importer/import.php

<?php
$latin1 = "Caf\xE9";               // "Café" in ISO-8859-1, as an old CSV export stores it
echo utf8_encode($latin1), "\n";

Output on PHP 8.1.34

Café

Output on PHP 8.2.34

Deprecated: Function utf8_encode() is deprecated in /var/www/html/wp-content/plugins/old-importer/import.php on line 3
Café

The replacement, and a case where the old function quietly produced wrong characters, are in “utf8_encode() is deprecated”.

Callbacks written as "self::method"

A plugin can pass one of its own methods as a callback in several ways. PHP 8.2 deprecates the ones that start with self, parent or static as text. php.net: “Callables that are not accepted by the $callable() syntax (but are accepted by call_user_func()) are deprecated.” (php.net)

wp-content/plugins/price-list/price-list.php

<?php
class Price_List {
    public static function format($price) {
        return number_format($price, 2);
    }

    public static function all(array $prices) {
        return array_map('self::format', $prices);
    }
}

echo implode(', ', Price_List::all([5, 12.5])), "\n";

Output on PHP 8.1.34

5.00, 12.50

Output on PHP 8.2.34

Deprecated: Use of "self" in callables is deprecated in /var/www/html/wp-content/plugins/price-list/price-list.php on line 8
5.00, 12.50

Encodings in mbstring functions

mb_convert_encoding() with HTML-ENTITIES was a shortcut for turning accented letters into HTML codes. php.net: “Usage of the QPrint, Base64, Uuencode, and HTML-ENTITIES ’text encodings’ is deprecated for all MBString functions.” (php.net)

wp-content/plugins/old-importer/import.php

<?php
echo mb_convert_encoding('Café', 'HTML-ENTITIES', 'UTF-8'), "\n";

Output on PHP 8.1.34

Caf&eacute;

Output on PHP 8.2.34

Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in /var/www/html/wp-content/plugins/old-importer/import.php on line 2
Caf&eacute;

PHP’s own notice names the replacements, so whoever fixes it knows where to start.

What changes silently

Some PHP 8.2 changes give no message at all. The one most likely to matter in a WordPress site, from php.net: “strtolower(), strtoupper(), stristr(), stripos(), strripos(), lcfirst(), ucfirst(), ucwords(), and str_ireplace() are no longer locale-sensitive.” (php.net) On a server set to a language with special letters, these functions used to change their case; from PHP 8.2 they only change A to Z. php.net: “Localized versions of these functions are available in the MBString extension.” (php.net)

No code check can tell whether a plugin relied on the old behaviour; a quick look at text with accented capital letters after the switch does.

How to check your site before switching

  1. Find your PHP version: Tools → Site Health → Info → Server. Checking and changing your PHP version shows where, and how to switch.
  2. Check your plugins and theme for the version you’re moving to. CompatNav reports each change above where the code shows it, with the file and line.
  3. Update what has an update (Dashboard → Updates), and send the rest to their developers.
  4. Switch, then watch the error log for a few days: the WordPress debug log explains how to keep one without showing messages to visitors.

Key takeaways

  • PHP 8.2 was released on 8 December 2022 and gets security fixes until 31 December 2026 (php.net). WordPress 6.1 and later are compatible with it.
  • Most PHP 8.2 changes you’ll meet in plugins and themes are deprecation notices: the code keeps working.
  • The common ones: dynamic properties, "${var}" in strings, utf8_encode() and utf8_decode(), "self::method" callbacks, HTML-ENTITIES in mbstring functions.
  • Silent changes: strtolower() and related functions no longer follow the server’s locale.
  • Already on PHP 8.2? Its end of support is close: check your plugins and theme for 8.3, 8.4 or 8.5 and move on.

Frequently asked questions

Is WordPress compatible with PHP 8.2?

Yes. The WordPress core team’s compatibility page lists WordPress 6.1 and later as compatible with PHP 8.2. Your plugins and theme are a separate question, and the changes on this page are about them.

Will my site break on PHP 8.2?

Usually not because of PHP 8.2 itself: the changes plugins and themes most often meet only add deprecation notices. Code that already broke on PHP 8.0 or 8.1 still breaks, so if you come from PHP 7.4, read about the move to PHP 8 first.

Should I upgrade to PHP 8.2 now?

Only as a step. PHP 8.2 gets security fixes until 31 December 2026; PHP 8.3 until 31 December 2027, 8.4 until 31 December 2028, 8.5 until 31 December 2029. If your plugins and theme are ready, a newer version gives you more time.

How do I hide the PHP 8.2 deprecation notices?

Log them instead of showing them: turn off WP_DEBUG_DISPLAY and keep a log, as explained in our guide to the WordPress debug log. Hiding them doesn’t fix them; updating the plugin does.

Check your own site before you upgrade

CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.

Get CompatNav on wordpress.org How it works

Sources

About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.