Deprecated Warning: Creation of dynamic property $unique_block_class in tds_w_fa

Posted in: Newspaper
Post count: 87

Hello
I’m getting the following PHP deprecation warning on my website:
Deprecated: Creation of dynamic property tds_w_favorite1::$unique_block_class is deprecated in /home/u707263619/domains/grookfit.com/public_html/wp-content/plugins/td-woo/styles/tds_w_favorite/tds_w_favorite1.php on line 17
After checking the file, I found that the issue was due to creating a dynamic property directly on the class, which is deprecated in newer PHP versions (8.2+).
To fix the issue, I modified the code as follows:
Before (original code):
$this->unique_block_class = $td_block_layout->get_unique_block_class();

After (fixed code):

if (property_exists($this, 'unique_block_class')) {
$this->unique_block_class = $td_block_layout->get_unique_block_class();
}

or alternatively, I declared the property inside the class definition like this:

class tds_w_favorite1 extends td_block {
public $unique_block_class;

function __construct() {
$this->unique_block_class = $td_block_layout->get_unique_block_class();
}
}

This resolved the deprecated notice successfully.

I just wanted to confirm if this is the correct and recommended approach for this plugin.

Post count: 35449

Hi,
Thank you for letting us know about this. Our developers will check it out and fix it for the coming theme update.
Thankyou!

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.