Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created November 7, 2024 13:16
Show Gist options
  • Save andrasguseo/6487599e0b8cc8a870beee2cf4de531e to your computer and use it in GitHub Desktop.
Save andrasguseo/6487599e0b8cc8a870beee2cf4de531e to your computer and use it in GitHub Desktop.
TEC > Change event content im the subscription feed
<?php
/**
* Changes the event title and description in the iCal feed which is used to export events or
* subscribe to the calendar. Can be used to prank subscribers to the calendar. :)
*
* Usage: Add the snippet with a plugin like Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar
*
* @since November 6, 2024 Initial version.
*/
add_filter( 'tribe_ical_feed_item', function ( $item ) {
$item['SUMMARY'] = 'SUMMARY:' . generate_muppets_event_title();
$item['DESCRIPTION'] = 'DESCRIPTION:' . generate_muppets_event_description();
unset( $item['URL'] );
unset( $item['LOCATION'] );
unset( $item['CATEGORIES'] );
unset( $item['ATTACH'] );
unset( $item['ORGANIZER'] );
unset( $item[0] ); // For GEO
unset( $item[1] ); // For X-APPLE-STRUCTURED-LOCATION
return $item;
} );
/**
* Function to generate a random Muppet event title.
*/
function generate_muppets_event_title() {
// Arrays of characters, verbs, and nouns inside the function
$muppets = [ "Kermit", "Miss Piggy", "Fozzie Bear", "Gonzo", "Animal", "Rowlf", "Swedish Chef", "Beaker", "Statler", "Waldorf", "Dr. Teeth", "Janice", "Sam Eagle" ];
$verbs = [ "Celebrates", "Hosts", "Explores", "Masters", "Presents", "Performs", "Dances with", "Discovers", "Investigates", "Launches", "Competes in" ];
$nouns = [ "Jazz Extravaganza", "Laughter Gala", "Talent Showdown", "Singing Contest", "Wild Cooking Show", "Laugh-a-thon", "Art Festival", "Mystery Night", "Puppet Parade", "Dance Off", "Magic Show", "Movie Marathon", "Science Fair" ];
// Generate a random event title
$character = $muppets[ array_rand( $muppets ) ];
$verb = $verbs[ array_rand( $verbs ) ];
$noun = $nouns[ array_rand( $nouns ) ];
return "$character $verb the $noun";
}
/**
* Function to generate a random Muppet event description.
*/
function generate_muppets_event_description() {
$remarks = [
"That was terrible!",
"I've seen better performances in a dentist's waiting room!",
"Why do we keep coming back here?\\nBecause we're too old to go anywhere else!",
"You know\, that wasn't half bad!\\nYou're right\, it was all bad!",
"You know\, that was actually pretty good!\\nYeah\, not bad at all!\\nIn fact\, I'd say it was...almost enjoyable!\\nAlmost...except for the singing\, dancing\, and jokes.",
"That was the best show we've had all week!\\nIt was the only show we had all week!",
"You know\, I've never seen a show like this before.\\nNo one has. That's why we're still here.",
"I've been waiting for this moment my whole life!\\nIt's been a long wait\, hasn't it?",
"That was a great performance!\\nFor a guy with no talent\, it was amazing.",
"The show's almost over!\\nI know\, and I can hardly wait!\\nYou can hardly wait for the show to end?\\nNo\, for the check to clear!",
"That was a fantastic performance!\\nYou mean\, it was better than most of the shows we've seen here.\\nThat's not saying much!",
];
return $remarks[ array_rand( $remarks ) ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment