想到弄博客了,折腾了好久的wordpress,写几个自己遇到的问题和解决方法。
其实百度上都能找到答案。(后台卡和中文用户名)
第一个,关于帐户中文名,当建立好博客的时候使用中文用户名,就会被告知非法字符
所以需要去修改一个文件,然后来刷新页面就可以了,原理什么就不说了,
我也不懂,只说方法:
修改文件 wp-includes/formatting.php 编辑
function sanitize_user( $username, $strict = false ) {
$strict = false;
$raw_username = $username;
$username = wp_strip_all_tags( $username );
$username = remove_accents( $username );
其中
$strict = false;
这句代码是自己加上去的,改好后保存就OK了,然后去页面刷新就能输入中文名字了;
第二个:wordpress后台登陆超慢,原因据说是调用了谷歌字体的原因,改写代码有两种方法解决;
更新4.6之后应该是不会存在这个问题了
修改文件 这次修改是主题内的文件 wp-content/themes/<主题名字>/functions.php 编辑
方法一,调用360的谷歌字体(我自己用的方法)
在<!--?php 和 ?--> 内添加代码:
function wpdx_replace_open_sans() {
wp_deregister_style('open-sans');
wp_register_style( 'open-sans', '//fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600' );
if(is_admin()) wp_enqueue_style( 'open-sans');
}
add_action( 'init', 'wpdx_replace_open_sans' );
方法二:经用谷歌字体(没有操作过),在同样的地方添加代码:
//禁用Open Sans
class Disable_Google_Fonts {
public function __construct() {
add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );
}
public function disable_open_sans( $translations, $text, $context, $domain ) {
if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
}
$disable_google_fonts = new Disable_Google_Fonts;
这样大功告成了,是不是后台访问变快了,这样操作才爽快!
Comments | NOTHING