Skip to content

Instantly share code, notes, and snippets.

@jcasabona
Created December 6, 2018 12:13
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 jcasabona/400eb58e8c86dd5dc7bf806b33a687bd to your computer and use it in GitHub Desktop.
Save jcasabona/400eb58e8c86dd5dc7bf806b33a687bd to your computer and use it in GitHub Desktop.
WordPress Filter to Clean Google Docs Markup on Post Save
<?php
add_filter( 'content_save_pre', 'wpp_clean_google_docs' );
function wpp_clean_google_docs( $content ) {
if ( ! ( 'transcript' == get_post_type() ) ) {
return $content;
}
$search = array( '&nbsp;',
'</span>'
);
$content = str_replace( $search, '', $content );
return preg_replace( '/<span[^>]+\>/i', '', $content );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment