Created
January 1, 2026 18:04
-
-
Save Dan-Q/4d8ef5ca35119f4c1c8bcb5e06bee68d to your computer and use it in GitHub Desktop.
Code referenced by a ClassicPress/WordPress theme's functions.php to add RSS 'suffix messages', as used by DanQ.me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Returns the DEFAULT "thanks" message for a post. This is determined (functionally-)randomly, | |
| * using the ID of the post as the random seed. | |
| */ | |
| function q23_rss_thanks_default( $post ) { | |
| $rss_thanks_messages = [ | |
| "๐ RSS is fantastic, and so are you for using it. ๐", | |
| "๐ Congratulations on being an RSS user. ๐", | |
| "๐ฅฐ You're reading this post via the RSS feed. That makes you one of the best people on the Internet! ๐", | |
| "๐ฐ Using a feed reader is the best way to read my blog posts. How clever you are to know that! ๐", | |
| "๐ You're reading this post via the RSS feed, you star! ๐ ", | |
| "๐ช Feeds are wonderful, and you're a wonderful person for using them. ๐ฎ", | |
| "โค๏ธโ๐ฅ You're reading this post via the RSS feed. You're on fire! ๐ฅ", | |
| "๐งจ RSS is dynamite! Thanks for subscribing to my blog. ๐ฅ", | |
| "๐ค You're subscribed to DanQ.me using the RSS feed. You rock! ๐ธ", | |
| "๐ต๏ธ Subscribing to DanQ.me's RSS feeds means that you'll get to see secret bonus posts not publicised on the main site. Clever you! ๐ง ", | |
| "๐งก I love RSS feeds. And I love you for using them. ๐", | |
| "๐๏ธ Using RSS feeds is a great way to keep up-to-date with my blog. Thanks for subscribing! ๐ค", | |
| "๐ฆธ You're my hero! (For using RSS to follow my blog.) ๐ฅ", | |
| ]; | |
| $post_id = intval( $post ? $post->ID : 0 ); | |
| return $rss_thanks_messages[ $post_id % count( $rss_thanks_messages ) ]; | |
| } | |
| /** | |
| * Given post content, appends a "thanks for using RSS" message. | |
| * If the post has a 'rss_thanks_message' custom variable set, use that (this allows a post to | |
| * override the default message, which I sometimes use in posts specifically ABOUT RSS). | |
| * Otherwise, uses `q23_rss_thanks_default` to get the default message for this post. | |
| */ | |
| function q23_rss_thanks( $content ) { | |
| global $post; | |
| $rss_thanks_message = get_post_meta( $post->ID , 'rss_thanks_message', true ); | |
| $rss_thanks_message = empty( $rss_thanks_message ) ? q23_rss_thanks_default( $post ) : $rss_thanks_message; | |
| return $content . "<p style=\"margin-top: 0.5ch; padding-top: 0.5ch; border-top: 1px solid #ccc;\">$rss_thanks_message</p>"; | |
| } | |
| /** | |
| * When generating content for RSS feeds, consider adding a thanks message. | |
| */ | |
| add_action( 'the_content_feed', 'q23_rss_thanks' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment