disqus-wordpress-plugin icon indicating copy to clipboard operation
disqus-wordpress-plugin copied to clipboard

"Undefined property" error on non-post pages

Open columbian-chris opened this issue 5 years ago • 1 comments

The plugin works normally in my "post" type pages as expected, but it seems as though it's trying to load on pages it shouldn't. I would think that something like Disqus_Public::dsq_can_load or some other means would be communicating not to load on these pages because there's no $post object (these pages do not have the "post" post_type or call for a WP comments module that I can see anywhere). The notices thrown:

Trying to get property 'ID' of non-object in /vagrant/columbian/wp-content/plugins/disqus-comment-system/public/class-disqus-public.php on line 32
Trying to get property 'guid' of non-object in /vagrant/columbian/wp-content/plugins/disqus-comment-system/public/class-disqus-public.php on line 32

I slapped a bandaid on it to prevent this error from happening by creating a false $post object:

$post = (object) array(
	'ID' => null,
	'post_status' => null,
	'comment_status' => null,
	'post_type' => null,
	'guid' => null
);

columbian-chris avatar Nov 06 '19 22:11 columbian-chris

Is there maybe a way to not load the Disqus plugin at all in certain page templates?

columbian-chris avatar Nov 06 '19 22:11 columbian-chris