本 Blog 使用的是 WordPress,每次升级 WordPress 都须要修改文件,以修正一些问题,所以作个总记录,便于本身修改。php
解决 WordPress 没法打开中文连接的文章(服务器支持 UTF-8,再也不须要修改文件支持中文连接。)html
wp-includes/class-wp.php 153 行:web
153
|
$pathinfo
= isset(
$_SERVER
[
'PATH_INFO'
] ) ?
$_SERVER
[
'PATH_INFO'
] :
''
;
|
修改成:express
153
|
$pathinfo
= isset(
$_SERVER
[
'PATH_INFO'
] ) ? mb_convert_encoding(
$_SERVER
[
'PATH_INFO'
],
'utf-8'
,
'GBK'
) :
''
;
|
wp-includes/class-wp.php 157 行:服务器
157
|
list(
$req_uri
) =
explode
(
'?'
,
$_SERVER
[
'REQUEST_URI'
] );
|
修改成:curl
157
|
list(
$req_uri
) =
explode
(
'?'
, mb_convert_encoding(
$_SERVER
[
'REQUEST_URI'
],
'utf-8'
,
'GBK'
) );
|
解决 WordPress 自动把半角符号替换为全角符号ide
两种解决方案:(采起第二种解决方案,WordPress 升级不须要再次修改。)wordpress
第一种:(修改 Blog 程序文件)post
wp-includes/formatting.php 138 行与 140 行:ui
138
139
140
|
$curl
=
str_replace
(
$static_characters
,
$static_replacements
,
$curl
);
// regular expressions
$curl
= preg_replace(
$dynamic_characters
,
$dynamic_replacements
,
$curl
);
|
修改成:
138
139
140
|
// $curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
// $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
|
第二种:(修改主题中的 functions.php)
打开 functions.php 文件添加如下语句:
1
2
3
4
|
/* 禁止文章标题自动全半角转换 */
remove_filter(
'the_title'
,
'wptexturize'
);
/* 禁止文章内容自动全半角转换 */
remove_filter(
'the_content'
,
'wptexturize'
);
|
解决 WordPress 评论 aria-required=’true’,形成没法经过 W3C 验证
将 wp-includes/comment-template.php 全部 aria-required=’true’ 删除,1975 行:
1975
|
$aria_req
= (
$req
?
" aria-required='true'"
:
''
);
|
修改成:
1975
|
$aria_req
= (
$req
?
" "
:
''
);
|
wp-includes/comment-template.php,1998 行:
1998
|
'comment_field'
=>
'<p class="comment-form-comment"><label for="comment">'
. _x(
'Comment'
,
'noun'
) .
'</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>'
,
|
修改成:
1998
|
'comment_field'
=>
'<p class="comment-form-comment"><label for="comment">'
. _x(
'Comment'
,
'noun'
) .
'</label> <textarea id="comment" name="comment" cols="45" rows="8" ></textarea></p>'
,
|
解决 baidu-sitemap 插件在发布或修改文章出现 PHP Warning
关于 baidu-sitemap 插件,在发布和更新文章,出现的 PHP Warning: Illegal string offset ‘lc_is_update_sitemap_when_post’ in…… baidu-sitemap-generator\baidu_sitemap.php ,是由于缺乏 isset 而出现警告。当访问未定义变量时,PHP 会产生警告;所以须要用 empty() 或者 isset() 判断变量是否认义。
baidu-sitemap.php 文件中的第 406 行:
406
|
if
(
$get_baidu_sitemap_options
[
'lc_is_update_sitemap_when_post'
] ==
'1'
)
|
修改成:
406
|
if
(isset(
$get_baidu_sitemap_options
[
'lc_is_update_sitemap_when_post'
]) ==
'1'
)
|
参考资料: