關於 Blog 修改

關於 Blog 修改

本 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' )

參考資料:



相關文章
相關標籤/搜索