Similarly to what was done in Chapter 2, Plugin Framework Basics, in the Adding text after each item's content using plugin filters recipe, this recipe registers a callback with the the_content filter hook, which allows us to add an additional link after each post or page where the source name and source address fields have been filled in. We use the get_post_type function in our callback to first check whether the item being displayed is in one of these two categories. Then, we use get_post_meta to retrieve the information and display the source link if both fields contain information.
We also use the esc_url and esc_html functions as a precaution to be sure that the data stored in these two post meta fields is clean.