\d+){font-weight:bold}#', $contents[ 'contents' ], $boldmatches); preg_match('#.c(?P\d+){font-style:italic}#', $contents[ 'contents' ], $italicmatches); if( isset( $boldmatches[ 'digit' ] ) ) $contents[ 'contents' ] = preg_replace( '#(.*?)#s', '$3', $contents[ 'contents' ] ); if( isset( $italicmatches[ 'digit' ] ) ) $contents[ 'contents' ] = preg_replace( '#(.*?)#s', '$3', $contents[ 'contents' ] ); return $contents; } add_filter( 'pre_docs_to_wp_insert', 'dtwp_clean_content_filter', 10, 1 ); function dtwp_clean_content_filter( $post_array ) { $original_content = $post_array[ 'post_content' ]; $cleaned_content = dtwp_clean_content( $original_content ); $post_array[ 'post_content' ] = $cleaned_content[ 'content' ]; $post_array['custom_fields'] = array_merge( $post_array['custom_fields'], array( '_gdocs_comments' => $cleaned_content[ 'comments' ] ) ); return $post_array; } function dtwp_clean_content($post_content) { $post_content = str_replace( array( "\r\n", "\n\n", "\r\r", "\n\r" ), "\n", $post_content ); $post_content = preg_replace('//', '
', $post_content); $post_content = preg_replace('//', '

', $post_content); //Match all the comments into an array. We're doing this before anything else because the

is importqnt preg_match_all( '/

\[[\w]\]<\/a>(.*?)<\/div>/', $post_content, $comments, PREG_PATTERN_ORDER); $comments = implode( "\r\n\r\n", $comments[1] ); //Take out the comments $post_content = preg_replace( '/

/', '', $post_content ); $post_content = str_replace( '

', '

',$post_content ); $post_content = strip_tags($post_content, '