I have the following filter but when I save the post some of the post content gets deleted. Is there an alternate solution?
function filter_post_data( $data, $postarr ){
$content = $data['post_content'];
$title = $data['post_title'];
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(150),
chr(151)
);
$replace = array("'",
"'",
"'",
"'",
"-",
"-"
);
$contentSanitized = str_replace($search, $replace, $content);
$titleSanitized = str_replace($search, $replace, $title);
$data['post_content'] = $contentSanitized;
$data['post_title'] = $titleSanitized;
//print_r($data);
return $data;
}
add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 );
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]