Totally Zenned
- Join Date:
- Jan 2007
- Posts:
- 1,514
- Plugin Contributions:
- 1
Can someone please help me to modify this sanitizer function for Google Base Feeder?
I've been tinkering around with the code a bit to try to get it to work the way I want but need some advice about the regular expressions.
The way the Google Base Feeder is now, all & and " gets stripped out of the XML file. I entered the & and " as & and " when I created the product listings. I don't know if ZC changes it to & and ". Anyway, the Feed creator strips them out and I would like to leave them in the title and descriptions.
Here is the zen_xml_sanitizer function:
function zen_xml_sanitizer ($str) {
$_strip_search = array("![\t ]+$|^[\t ]+!m",'%[\r\n]+%m'); // remove CRs and newlines
$_strip_replace = array('',' ');
$_cleaner_array = array(">" => "> ", "®" => "", "®" => "", "™" => "", "™" => "", "\t" => "", " " => "");
$str = html_entity_decode($str);
$str = strtr($str, $_cleaner_array);
$str = preg_replace($_strip_search, $_strip_replace, $str);
$str = strip_tags($str);
$str = eregi_replace("[^[:alnum:][:space:].,!()'-_/+=?]", "", $str);
$str = htmlentities($str);
$str = str_replace('&', '&', $str);
return $str;
}
What needs to be changed to leave " alone, it doesn't affect the XML file, and change the & to &? I'm almost there but not quite!:huh:
Thanks!
Matt