Skip to content

Instantly share code, notes, and snippets.

@cfxd
Last active June 6, 2020 23:49
Show Gist options
  • Save cfxd/282816d1a4332c31f870c107dfac7b06 to your computer and use it in GitHub Desktop.
Save cfxd/282816d1a4332c31f870c107dfac7b06 to your computer and use it in GitHub Desktop.
Error Publishing to Apple News With the WordPress Plugin. See https://cfxdesign.com/error-publishing-to-apple-news-with-the-wordpress-plugin/
function apple_news_remove_empty_p_tags($content, $post_id) {
$new_content = preg_replace('/<span[^>]*>[\s\040\t\r\n\W]*<\/span>/', '', $content);
$new_content = preg_replace('/<span[^>]*>&nbsp;*<\/span>/', '', $new_content);
$new_content = preg_replace('/<span[^>]*> <\/span>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*>[\s\040\t\r\n\W]*<\/p>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*>&nbsp;*<\/p>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*> <\/p>/', '', $new_content);
return $new_content;
}
add_filter('apple_news_exporter_content', __NAMESPACE__.'\\apple_news_remove_empty_p_tags', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment