/** * Switcheroo! Raw XML content gets switched with HTML formatted content. * Save the raw XML to the post_content_formatted column * Save the formatted HTML to the post_content column */ function anno_insert_post_data($data, $postarr) { // This is the quick edit action, we don't want to mess around with the content. if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { return $data; } $is_article_type = false; // Both published and drafts (before article ever saved) get caught here if ($postarr['post_type'] == 'article') { $is_article_type = true; } // If we're a revision, we need to do one more check to ensure our parent is an article if ($postarr['post_type'] == 'revision') { if (!empty($data['post_parent']) && get_post_type($data['post_parent']) == 'article') { $is_article_type = true; } } if ($is_article_type) { // Get our XML content for the revision $content = stripslashes($data['post_content']); // Remove non-ascii gremlins $content = preg_replace('/(\\xa0|\\xc2)/', '', $content); $content = str_replace(array("\r", "\r\n", "\n"), '', $content); // Set XML as backup content. Filter markup and strip out tags not on whitelist. $xml = anno_validate_xml_content_on_save($content); $data['post_content_filtered'] = addslashes($xml); // Set formatted HTML as the_content $data['post_content'] = addslashes(anno_xml_to_html($xml)); } return $data; }
/** * Switcheroo! Raw XML content gets switched with HTML formatted content. * Save the raw XML to the post_content_formatted column * Save the formatted HTML to the post_content column */ function anno_insert_post_data($data, $postarr) { // This is the quick edit action, we don't want to mess around with the content. if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { return $data; } if ($postarr['post_type'] == 'article' || defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && get_post_type($postarr['post_parent']) == 'article') { // Get our XML content for the revision $content = stripslashes($data['post_content']); // Remove non-ascii gremlins $content = preg_replace('/(\\xc2\\xa0)/', ' ', $content); $content = str_replace(array("\r", "\r\n", "\n"), '', $content); // Set XML as backup content. Filter markup and strip out tags not on whitelist. $xml = anno_validate_xml_content_on_save($content); $data['post_content_filtered'] = addslashes($xml); // Set formatted HTML as the_content $data['post_content'] = addslashes(anno_xml_to_html($xml)); $data['post_excerpt'] = addslashes(anno_validate_xml_content_on_save(stripslashes($data['post_excerpt']))); } return $data; }
function anno_process_xml_content($content) { if (get_post_type() == 'article') { remove_filter('the_content', 'wpautop'); $post = get_post(); $content = anno_xml_to_html($post->post_content_filtered); } return $content; }