Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove invalid line breaks and returns from invalid source XML feed
<?php
/*
Script Name: getcleanfeed
Plugin URI: https://premium.wpmudev.org/
Description: Removes invalid line breaks and returns from source feed
Author: James Morris @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sourcesite.com/feed/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$string = str_replace(array("\r", "\n", "\r\n"), ' ', $output);
echo file_put_contents("outputfeed.xml", $string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment