﻿{"id":54263,"date":"2025-05-20T22:32:54","date_gmt":"2025-05-20T22:32:54","guid":{"rendered":"https:\/\/bookwormhead.com\/?p=54263"},"modified":"2026-04-18T12:56:55","modified_gmt":"2026-04-18T12:56:55","slug":"php-deprecated-dynamic-property-warnings-in-wordpres","status":"publish","type":"post","link":"https:\/\/bookwormhead.com\/cms\/php-deprecated-dynamic-property-warnings-in-wordpres\/","title":{"rendered":"Fixing PHP 8.2 \u201cDeprecated Dynamic Property\u201d Warnings in WordPress (Divi + Other Plugins)"},"content":{"rendered":"<p>If you&#8217;re seeing warnings like this:<\/p>\n<p>[code_block]<br \/>\nDeprecated: Creation of dynamic property DLK_Builder_Module_Course_Content::$icon is deprecated..<br \/>\n[\/code_block]<\/p>\n<p data-start=\"621\" data-end=\"859\">You&#8217;re likely running PHP 8.2+ and using Divi or a custom-built module. PHP 8.2 deprecated dynamic properties, meaning any code that creates new class properties on the fly (without declaring them first) will now trigger warnings.<\/p>\n<p data-start=\"861\" data-end=\"997\">This guide gives you three practical options \u2014 from quick fixes to long-term solutions \u2014 tailored for Divi-based WordPress projects.<\/p>\r\n    <div class=\"bwh-in-article-ad\">\r\n      <ins class=\"adsbygoogle\"\r\n           style=\"display:block; text-align:center;\"\r\n           data-ad-client=\"ca-pub-4299086769596754\"\r\n           data-ad-slot=\"8699383760\"\r\n           data-ad-format=\"auto\"\r\n           data-full-width-responsive=\"true\"><\/ins>\r\n      <script>\r\n        (adsbygoogle = window.adsbygoogle || []).push({});\r\n      <\/script>\r\n    <\/div>\n<hr data-start=\"999\" data-end=\"1002\" \/>\n<h2 data-start=\"1004\" data-end=\"1054\">Option 1: Downgrade to PHP 8.1 (Quickest Fix)<\/h2>\n<p data-start=\"1056\" data-end=\"1156\">If you&#8217;re in a local or development environment, the fastest way to stop the deprecated warnings is:<\/p>\n<p data-start=\"1158\" data-end=\"1198\">Downgrade your PHP version to 8.1<\/p>\n<p data-start=\"1200\" data-end=\"1299\">PHP 8.1 doesn\u2019t issue deprecation warnings for dynamic properties, so everything works like before.<\/p>\n<h3 data-start=\"1301\" data-end=\"1319\">When to Use:<\/h3>\n<ul data-start=\"1320\" data-end=\"1420\">\n<li data-start=\"1320\" data-end=\"1372\">\n<p data-start=\"1322\" data-end=\"1372\">You&#8217;re debugging locally or under a tight timeline<\/p>\r\n    <div class=\"bwh-in-article-ad\">\r\n      <ins class=\"adsbygoogle\"\r\n           style=\"display:block; text-align:center;\"\r\n           data-ad-client=\"ca-pub-4299086769596754\"\r\n           data-ad-slot=\"8699383760\"\r\n           data-ad-format=\"auto\"\r\n           data-full-width-responsive=\"true\"><\/ins>\r\n      <script>\r\n        (adsbygoogle = window.adsbygoogle || []).push({});\r\n      <\/script>\r\n    <\/div>\n<\/li>\n<li data-start=\"1373\" data-end=\"1420\">\n<p data-start=\"1375\" data-end=\"1420\">You don\u2019t want to touch module code right now<\/p>\n<\/li>\n<\/ul>\n<h3 data-start=\"1422\" data-end=\"1448\">Why It\u2019s Temporary:<\/h3>\n<p data-start=\"1449\" data-end=\"1617\">PHP 8.2+ offers better performance and is future-proof. Plus, PHP 9.0 will remove dynamic property support completely \u2014 so updating your code is eventually unavoidable.<\/p>\n<hr data-start=\"1619\" data-end=\"1622\" \/>\n<h2 data-start=\"1624\" data-end=\"1684\">Option 2: Refactor Custom Divi Modules (Best Practice)<\/h2>\n<p data-start=\"1686\" data-end=\"1830\">If you&#8217;re overriding Divi modules or creating custom ones, PHP 8.2 will throw warnings unless you declare all dynamic properties explicitly.<\/p>\n<h3 data-start=\"1832\" data-end=\"1851\">Example Fix:<\/h3>\n<p data-start=\"1853\" data-end=\"1888\">Before (causes warning in PHP 8.2):<\/p>\n<p>[code_block lang=&#8221;js&#8221;]<br \/>\nclass DLK_Builder_Module_Payment_Buttons extends ET_Builder_Module {<br \/>\npublic function __construct() {<br \/>\n$this-&gt;fb_support = true;<br \/>\n$this-&gt;icon = &#8216;e005&#8217;;<br \/>\nparent::__construct();<br \/>\n}<br \/>\n}[\/code_block]<\/p>\n<p data-start=\"2109\" data-end=\"2134\">After (safe in PHP 8.2+):<\/p>\n<p>[code_block]class DLK_Builder_Module_Payment_Buttons extends ET_Builder_Module {<br \/>\npublic $fb_support = true;<br \/>\npublic $icon = &#8216;e005&#8217;;public function __construct() {<br \/>\nparent::__construct();<br \/>\n}<br \/>\n}[\/code_block]<\/p>\n<h3 data-start=\"2350\" data-end=\"2392\">Not Sure If Your Module Is Running?<\/h3>\n<p data-start=\"2394\" data-end=\"2434\">Add this to functions.php temporarily:<\/p>\n<p>[code_block]add_action(&#8216;init&#8217;, function () {<br \/>\nerror_log(&#8216;\u2705 DLK Custom Module is loaded&#8217;);<br \/>\n});[\/code_block]<\/p>\n<p data-start=\"2533\" data-end=\"2567\">Then check wp-content\/debug.log.<\/p>\n<p data-start=\"2569\" data-end=\"2738\">If you see this log, it confirms your module is active \u2014 but if the deprecation notice still appears, Divi may be loading its core version before your override runs.<\/p>\n<p data-start=\"2740\" data-end=\"2777\">In that case, move to Option 3 below.<\/p>\n<hr data-start=\"2779\" data-end=\"2782\" \/>\n<h2 data-start=\"2784\" data-end=\"2863\">Option 3: Suppress Warnings Using a mu-plugin (Recommended for Live Use)<\/h2>\n<p data-start=\"2865\" data-end=\"3003\">If you want to keep PHP 8.2 but silence these harmless warnings, the most reliable method is to use a mu-plugin (must-use plugin).<\/p>\n<h3 data-start=\"3005\" data-end=\"3024\">Step-by-Step<\/h3>\n<h4 data-start=\"3026\" data-end=\"3073\">1. Create this folder if it doesn\u2019t exist:<\/h4>\n<div>\n<div dir=\"ltr\">wp-content\/mu-plugins\/<\/div>\n<\/div>\n<h4 data-start=\"3106\" data-end=\"3139\">2. Inside it, create a file:<\/h4>\n<div>\n<div dir=\"ltr\">disable-deprecated-warnings.php<\/div>\n<\/div>\n<h4 data-start=\"3181\" data-end=\"3212\">3. Add the following code:<\/h4>\n<div>[code_block]<br \/>\nerror_reporting(E_ALL &amp; ~E_DEPRECATED &amp; ~E_USER_DEPRECATED);<br \/>\n[\/code_block]<\/p>\n<p data-start=\"3361\" data-end=\"3509\">Because mu-plugins load before everything else, this approach works even when functions.php or wp-config.php fails to suppress the warnings.<\/p>\n<\/div>\n<\/p>","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re seeing warnings like this: [code_block] Deprecated: Creation of dynamic property DLK_Builder_Module_Course_Content::$icon is deprecated.. [\/code_block] You&#8217;re likely running PHP 8.2+ and using Divi or a custom-built module. PHP 8.2 deprecated dynamic properties, meaning any code that creates new class properties on the fly (without declaring them first) will now trigger warnings. This guide gives [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,24],"tags":[45,74],"class_list":["post-54263","post","type-post","status-publish","format-standard","hentry","category-cms","category-technical","tag-divi","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/posts\/54263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/comments?post=54263"}],"version-history":[{"count":26,"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/posts\/54263\/revisions"}],"predecessor-version":[{"id":54420,"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/posts\/54263\/revisions\/54420"}],"wp:attachment":[{"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/media?parent=54263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/categories?post=54263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bookwormhead.com\/cms\/wp-json\/wp\/v2\/tags?post=54263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}