GFW 的问题,还好国内有 CDN 镜像。手动添加一个 function 就能解决。
打开后台 – 外观 – 主题编辑器 – 找到 funcions.php 然后找个地方添加以下代码:
add_filter('get_avatar', function ($avatar) { return str_replace([ 'www.gravatar.com/avatar/', '0.gravatar.com/avatar/', '1.gravatar.com/avatar/', '2.gravatar.com/avatar/', 'secure.gravatar.com/avatar/', 'cn.gravatar.com/avatar/' ], 'sdn.geekzu.org/avatar/', $avatar); });
以下是Gravatar CDN的网址:
极客族CDN:https://sdn.geekzu.org/
七牛Gravatar:https://dn-qiniu-avatar.qbox.me/
V2EX:https://cdn.v2ex.com/gravatar/
LOLI:https://gravatar.loli.net/avatar/
底部添加运行时间代码
<script type="text/javascript"> function show_runtime(){ window.setTimeout("show_runtime()",1000); X=new Date("12/12/2019 00:00:00"); Y=new Date(); T=(Y.getTime()-X.getTime()); M=24*60*60*1000; a=T/M; A=Math.floor(a); b=(a-A)*24; B=Math.floor(b); c=(b-B)*60; C=Math.floor(c); d=(c-C)*60; D=Math.floor(d); runtime_span.innerHTML="本站勉强运行:"+A+"天"+B+"小时"+C+"分"+D+"秒" } show_runtime(); </script> <span id="runtime_span"></span>
标签随机颜色
//标签彩色显示代码开始 function colorCloud($text) { $text = preg_replace_callback('|<a (.+?)>|i', 'colorCloudCallback', $text); return $text; } function colorCloudCallback($matches) { $text = $matches[1]; $colors=array('ff3300','0517c2','0fc317','e7cc17','601165','ffb900','f74e1e','00a4ef','7fba00'); $color=$colors[dechex(rand(0,3))]; $pattern = '/style=(\'|\")(.*)(\'|\")/i'; $text = preg_replace($pattern, "style=\"color:#{$color};$2;\"", $text); return "<a $text>"; } add_filter('wp_tag_cloud', 'colorCloud', 1); //介绍 $colors=array('ff3300','0517c2','0fc317','e7cc17','601165','ffb900','f74e1e','00a4ef','7fba00'); 是控制颜色显示的方法,可以根据自己喜欢的颜色轮番显示,默认是也可以给出一个范围来随机显示,如: $color = dechex(rand(0,16777215));
如果您的网站已经有很多文章图片,但是之前没有将图片设置链接到图片文件,可以批量为老图加链接
add_filter( 'the_content', function ( $content ) { $pattern = "/<img(.*?)src=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; $replacement = '<a href=$2$3.$4$5 rel="lightbox"><img$1href=$2$3.$4$5 rel="lightbox"$6></a>'; return preg_replace( $pattern, $replacement, $content ); } );