Убрать из шапки This site is optimized with the Yoast WordPress SEO plugin
Чтобы убрать из шапки код нужно немного поправить код файла class-frontend.php в папке плагина. После обновления плагина требуется повторить действия заново.
Строку:
1 |
add_action( 'wpseo_head', array( $this, 'debug_marker' ), 2 ); |
Заменяем на следующую. То есть комментируем ее.
1 |
// add_action( 'wpseo_head', array( $this, 'debug_marker' ), 2 ); |
Из строк:
1 2 3 4 5 6 7 |
function debug_marker( $echo = true ) { $marker = "<!-- This site is optimized with the Yoast WordPress SEO plugin v" . WPSEO_VERSION . " - http: / / yoast.com/wordpress/seo/ -->"; if ( !$echo ) return $marker; else echo "\n${marker}\n"; } |
Удаляется лишнее, чтобы получилось так:
1 2 3 4 5 6 7 |
function debug_marker( $echo = true ) { $marker = ""; if ( !$echo ) return $marker; else echo ""; } |
Строку:
1 |
$content = str_replace( $this->debug_marker( false ), $this->debug_marker( false ) . "\n" . '<title>' . $title . '</title>', $content ); |
Меняем на такую:
1 |
$content = str_replace( $this->debug_marker( false ), '<title>' . $title . "</title>\n", $content ); |
Строку просто удаляем.
1 |
echo "<!-- / Yoast WordPress SEO plugin. -->\n\n"; |
Рассказать:
Спасибо!
Все сработало
в functions.php используемой темы добавить
if (defined(‘WPSEO_VERSION’)){
add_action(‘get_header’,function (){ ob_start(function ($o){
return preg_replace(‘/\n?/mi’,»,$o); }); });
add_action(‘wp_head’,function (){ ob_end_flush(); }, 999);
}