Skip to content

Instantly share code, notes, and snippets.

@JRMorris77
Created March 15, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JRMorris77/d75b6729b2cbf0faefd152b12f1a9a8e to your computer and use it in GitHub Desktop.
Save JRMorris77/d75b6729b2cbf0faefd152b12f1a9a8e to your computer and use it in GitHub Desktop.
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