Skip to content

Instantly share code, notes, and snippets.

@kadimi
Last active April 28, 2024 18:57
Show Gist options
  • Save kadimi/c0b4c8f918524d403848b2eb048377c0 to your computer and use it in GitHub Desktop.
Save kadimi/c0b4c8f918524d403848b2eb048377c0 to your computer and use it in GitHub Desktop.
SportsPress: Replace line breaks with `\n` in iCal feeds
<?php
add_filter('posts_results', function($posts, $query) {
if (empty($_GET['feed']) || $_GET['feed'] !== 'sp-ical') {
return $posts;
}
foreach ($posts as &$post) {
$post->post_content = preg_replace("/\r?\n/", "\\n", $post->post_content);
}
return $posts;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment