这篇文章主要是记录wordpress在维护中出现的修改记录,方便日后查阅。
所有修改点,会一直持续更新。
个人不是很喜欢seo插件,只想让博客简单就好,因此可以手动添加一端seo到代码中即可。
找到现在使用的模板对应的header显示文件,修改显示内容为:
为了提高网站访问速度,图片进行升级,迁移到了阿里云cdn上面。阿里云的cdn支持域名指向,因此将static.ranshy.com指向了阿里云服务器,确保了博客图片地址依旧采用ranshy.com的域名。
问题是博客支持https访问,而https访问需要服务器提供证书,没有办法将证书上传到阿里云的cdn,因此https访问只能使用阿里云的域名。域名切换的实现,修改插件文件wp-content\plugins\wp-code-highlight\wp-code-highlight.php。
#shy add
if($_SERVER['HTTPS'] == 'on')
{
$content = str_replace('http://love.ranshy.com/wp-content/uploads', 'https://static.ranshy.com', $content);
}
else
{
$content = str_replace('love.ranshy.com/wp-content/uploads', '7xi8tc.com1.z0.glb.clouddn.com', $content);
}
preg_match_all('/(?<!a)[^<]+<img[^>]+src=[\'"]([^\'"]+)[\'"][^>]+>/', $content, $matches);
if($matches && $matches[1]) foreach($matches[1] as $match) {
$content = preg_replace('@<img[^>]+src=[\'"]' . $match . '[\'"][^>]+>@',
'<a href="' . $match . '"><img src="' . $match . '" class="aligncenter size-full" /></a>',
$content);
}
#add end
if(get_option('wp_code_highlight_line_numbers')=='enable'){
$line_numbers=' linenums:1';
}
else{
$line_numbers='';
}
return preg_replace("/<pre(.*?)>(.*?)<\/pre>/ise",
"'<pre class="wp-code-highlight prettyprint$line_numbers">'.wch_stripslashes('$2').'</pre>'", $content);
}
修改wp-includes文件夹下的post-thumbnail-template.php文件,该文件控制了所有的图片展示,修改the_post_thumbnail方法如下:
$url = get_the_post_thumbnail( null, $size, $attr );
if(!$_SERVER['HTTPS']) {
$url = str_replace('love.ranshy.com/wp-content/uploads', '7xi8tc.com1.z0.glb.clouddn.com', $url);
}
else
{
$url = str_replace('love.ranshy.com/wp-content/uploads', 'static.ranshy.com', $url);
}
echo $url;
}
网站的ico:16*16
文章图片:400*200
找到现在使用的模板对应的footer显示文件,修改显示内容为:
在WordPress中,经常遇到在后台添加新文章时,在内容中输入连续两个减号“–”,但在前台显示时,被转换成了破折号。
为了解决这个问题,我们可以添加一个名叫Quotmarks Replacer的WordPress插件。
7. 安全
shy
xiazhibingxue
Leave a Reply