删除 WP Rocket 插件的前台注释 删除隐藏在页面中的广告

Wordpress插件 WP-rocket是一个非常易于使用的缓存生成和管理插件,可以大大提高网站的访问速度。然而,无论你是否付费,它的开发者都会在你的网站之上留下广告。感觉就像他们在你家里塞满了每个人都能看到的广告。

如下图所示:


接下来告诉如何删除它的


删除方法

WP rocket自2.0版以后添加了 get_rocket_footprint() 方法在页面源代码的末尾添加尾部示意图,即下面的段落。编辑下列路径之中的wordpress文件以删除它们。

/wp-content/plugins/wp-rocket/inc/classes/Buffer/class-cache.php

这边我用的版本 3.9.x 大约是436行开始的。你可以看到 get_rocket_footprint() 方法,大致如下:

private function get_rocket_footprint( $time = '' ) {
		$footprint = defined( 'WP_ROCKET_WHITE_LABEL_FOOTPRINT' ) ?
						"\n" . '<!-- Cached for great performance' :
						"\n" . '<!-- This website is like a Rocket, isn\'t it? Performance optimized by ' . WP_ROCKET_PLUGIN_NAME . '. Learn more: https://wp-rocket.me';
		if ( ! empty( $time ) ) {
			$footprint .= ' - Debug: cached@' . $time;
		}
		$footprint .= ' -->';
		//return $footprint;  /*不返回注释 去除广告注释*/
	}

只需在末尾注释掉返回值 return 并使其不返回值

由于插件通常处于不断更新的周期之中,具体位置可能会发生变化。在这种情况之下,您可以在本地下载插件文件,使用Visual Studio代码或其他编辑工具全局查找插件文件,搜索关键字“this website”或“performance optimized”,然后在查找之后对其进行注释或删除。

- END -


文章链接:https://www.ityinhu.com/584.html

作者邮箱:ponyj@qq.com