Adding '&& get_queried_object_id() == $post->ID' in the 'IF' (function: collect_bibliography) will only run the function on the main query and not on possible widgets (eg. Recent Post Widget).
NB. Sorry if I made a bit of a mess of the pull request. If the pull request does not work properly, you can remove it and contact me. Then I'll do it again.
Adding '&& get_queried_object_id() == $post->ID' in the 'IF' (function: collect_bibliography) will only run the function on the main query and not on possible widgets (eg. Recent Post Widget). NB. Sorry if I made a bit of a mess of the pull request. If the pull request does not work properly, you can remove it and contact me. Then I'll do it again.