Forked from llgruff/Remove SEO-plugin HTML comments.php
Created
July 25, 2018 06:53
-
-
Save bewho/85915d134dde3e77f6721b29802e2c83 to your computer and use it in GitHub Desktop.
Remove [All in One SEO Pack] or [Yoast SEO] HTML Comments in WordPress (for functions.php)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Remove [All in One SEO Pack] HTML Comments | |
| * @link //gist.github.com/llgruff/a7ab776167aa0ed307ec445df54e5fdb | |
| */ | |
| if (defined('AIOSEOP_VERSION')) { | |
| add_action('get_header', function() { | |
| ob_start( | |
| function($o) { | |
| return preg_replace('/\n?<.*?One SEO Pack.*?>/mi','',$o); | |
| } | |
| ); | |
| }); | |
| add_action('wp_head', function() { | |
| ob_end_flush(); | |
| }, 999); | |
| } | |
| /** | |
| * Remove [Yoast SEO] HTML Comments | |
| * @link //gist.github.com/llgruff/a7ab776167aa0ed307ec445df54e5fdb | |
| * @link //gist.github.com/paulcollett/4c81c4f6eb85334ba076 | |
| */ | |
| if (defined('WPSEO_VERSION')) { | |
| add_action('get_header', function() { | |
| ob_start( | |
| function($o) { | |
| return preg_replace('/\n?<.*?yoast.*?>/mi','',$o); | |
| } | |
| ); | |
| }); | |
| add_action('wp_head', function() { | |
| ob_end_flush(); | |
| }, 999); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment