Hello,
I get the exact same error on the main page XYZ PHP Code in WP Admin, above the section with snippets. I have 4 snippets and get 4 Warnings (related?):
Warning: Attempt to read property “ID” on null in D:\xampp\htdocs\\wp-content\plugins\insert-php-code-snippet\xyz-functions.php on line 76.
In my case it is related to testing my site in a staging environment to test for PHP 8 fitness.
So, without any changes to the site, the plugin works fine in PHP 7.4 and throws this warning in PHP 8.
No drafts exist.
It looks like it has to do with the increased strictness of PHP 8 concerning variables and identifiers.
Something like $post or ID not having a value yet?
I had a few issues with other plugins that I could solve myself, all related to PHP 8 being less forgiving than PHP 7.
I’m not a programmer and don’t “speak” PHP.
I added an @ in front of $ (so: @$post) on line 76 and the warnings were gone. But I don’t know if that is a good idea:-).
Regards, Han
-
This reply was modified 2 years, 1 month ago by
hanvroon.