Skip to content

Instantly share code, notes, and snippets.

@nickstewart95
Last active December 15, 2020 03:31
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 nickstewart95/61d14b67e9d1f71c7edb8be215ad08d3 to your computer and use it in GitHub Desktop.
Save nickstewart95/61d14b67e9d1f71c7edb8be215ad08d3 to your computer and use it in GitHub Desktop.
Blog.php
//Image Fix
$content = str_replace('src="/wp-content/"', 'src="https://viastudio.com/wp-content/"', $content);
//Gist
$content = preg_replace('/(?:https?:\/\/)?(?:www\.)?gist.github\.com([^\n]+)$/sm', '<gist src="$0"></gist>', $content);
//Youtube
$content = preg_replace('/(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([^\n]+)$/sm', '<videoblock src="$0"></gist>', $content);
//Apply the content filters
$content = apply_filters('the_content', $content);
//Remove empty paragraphs
$content = str_replace('<p></p>', '', $content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment