如何解决wordpress4.1–zh_CN后台(仪表盘)慢的问题?
wordpress后台之所以慢是因为调用了google.com的一些资源,而google.com被墙掉了,所以当系统加载这些链接的时候会很慢,解决wordpress博客后台慢的问题,就是在博客的/wp-includes/script-loader.php 里换掉所有谷歌的链接都转成本站链接,以下就会告诉大家去替换哪些链接:
代码一:
在script-loader.php的第150——157行,将这些js下载放到自己博客空间里,并且替换掉链接
$scripts->add( 'prototype', '//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1'); $scripts->add( 'scriptaculous-root', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0'); $scripts->add( 'scriptaculous-builder', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0'); $scripts->add( 'scriptaculous-dragdrop', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0'); $scripts->add( 'scriptaculous-effects', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0'); $scripts->add( 'scriptaculous-slider', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0'); $scripts->add( 'scriptaculous-sound', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-controls', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');
我们已经下好这些js :
下载地址:http://pan.baidu.com/s/1i3vKfVB 密码: h858
代码二:
在script-loader.php的第607行访问 http://fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=4.1/ 可以看到以下代码。
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 300; src: local('Open Sans Light'), local('OpenSans-Light'), url(http://fonts.gstatic.com/s/opensans/v10/DXI1ORHCpsQm3Vp6mXoaTZS3E-kSBmtLoNJPDtbj2Pk.ttf) format('truetype'); } @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 400; src: local('Open Sans'), local('OpenSans'), url(http://fonts.gstatic.com/s/opensans/v10/cJZKeOuBrn4kERxqtaUH3SZ2oysoEQEeKwjgmXLRnTc.ttf) format('truetype'); } @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 600; src: local('Open Sans Semibold'), local('OpenSans-Semibold'), url(http://fonts.gstatic.com/s/opensans/v10/MTP_ySUJH_bn48VBG8sNSpS3E-kSBmtLoNJPDtbj2Pk.ttf) format('truetype'); } @font-face { font-family: 'Open Sans'; font-style: italic; font-weight: 300; src: local('Open Sans Light Italic'), local('OpenSansLight-Italic'), url(http://fonts.gstatic.com/s/opensans/v10/PRmiXeptR36kaC0GEAetxt6Naowg1QhaIq8kLGtQSos.ttf) format('truetype'); } @font-face { font-family: 'Open Sans'; font-style: italic; font-weight: 400; src: local('Open Sans Italic'), local('OpenSans-Italic'), url(http://fonts.gstatic.com/s/opensans/v10/xjAJXh38I15wypJXxuGMBiwlidHJgAgmTjOEEzwu1L8.ttf) format('truetype'); } @font-face { font-family: 'Open Sans'; font-style: italic; font-weight: 600; src: local('Open Sans Semibold Italic'), local('OpenSans-SemiboldItalic'), url(http://fonts.gstatic.com/s/opensans/v10/PRmiXeptR36kaC0GEAetxs1QGe9x6ME_FQCWJB3n6z8.ttf) format('truetype'); }
解决这个问题有两个方法:
方法一:很简单,删除这行代码就行了,缺点就是之前好看的字体没有了;
方法二:复制这些代码新建一个样式表并且将这个样式表放到博客的目录里,并且用这个目录替换掉 script-loader.php的第607行http://fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=4.1/。另外,下载好样式表里的所有字体,并且放到自己的博客服务器上,并替换好样式表里的字体链接;
我们下好了这些字体:
下载链接: http://pan.baidu.com/s/1mgEAQfu 密码: zdq4
代码三:
禁用头像连接禁用wordpress gravatar使用本地头像提高网页打开速度,WordPress默认的头像是读取gravatar.com上的图片的,对于国内用户来说会使网页打开速度变慢,修改get_avatar函数,在wp-includes/pluggable.php内。修改后的函数如下:
if ( !function_exists( 'get_avatar' ) ) : /** * Retrieve the avatar for a user who provided a user ID or email address. * * @since 2.5 * @param int|string|object $id_or_email A user ID, email address, or comment object * @param int $size Size of the avatar image * @param string $default URL to a default image to use if no avatar is available * @param string $alt Alternate text to use in image tag. Defaults to blank * @return string tag for the user's avatar */ function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { if ( ! get_option('show_avatars') ) return false; if ( false === $alt) $safe_alt = ''; else $safe_alt = esc_attr( $alt ); if ( !is_numeric($size) ) $size = '96'; $default = includes_url('images/blank.gif'); $avatar = ""; return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); } endif;
完成以上所有的步骤,回传 script-loader.php 到 /wp-includes 里,就大功告成了!