WordPress支持webp格式图片

将如下代码加入主题的functions.php或自己建立个插件写入内容

//让WORDPRESS支持WEBP格式图片
function webp_images_mime_types( $result ) {
    $result['webp'] = 'image/webp';
    return $result;
}

function webp_images_displayable($result, $path) {
    $info = @getimagesize( $path );
    if($info['mime'] == 'image/webp') {
        $result = true;
    }
    return $result;
}

add_filter( 'mime_types', 'webp_images_mime_types', 10, 1 );
add_filter( 'file_is_displayable_image', 'webp_images_displayable', 10, 2 );

解决WP“此响应不是合法的JSON响应。”

WordPress后台在5.X里新增加的古腾堡编辑器(Gutenberg)也许是太亲近大多数用户了,第一,很多功能其实找起来并不方便,其次,问题很多,例如大多数臃肿,兼容等问题,例如:

此响应不是合法的JSON响应。

还有发布文章时:

发布失败。此响应不是合法的JSON响应。

所以想用回原有编辑器,可以将以下代码放置在主题functions.php或者自己写个小插件(适合频繁更换主题或者使用商用主题的人)内:

//Wordpress 5.0+ 禁用 Gutenberg 编辑器
add_filter('use_block_editor_for_post', '__return_false');
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );

补充:古腾堡编辑器出现上述提示的原因还有可能是你服务器部分文件不可写,自动保存,还有REST API问题(查询一下是否做了屏蔽)等。但这些问题建议都先查询伪静态是否做好,尤其nginx环境。

查看REST API是否开着的方法:访问//你网站域名/wp-json/,看是否能打开整个页面的json,如果只有1行,就是被关闭了。

以下是可能造成屏蔽REST API的代码

add_filter('json_enabled', '__return_false');
add_filter('json_jsonp_enabled', '__return_false');
add_filter('rest_enabled', '__return_false');
add_filter('rest_jsonp_enabled', '__return_false');

remove_action('wp_head', 'rest_output_link_wp_head', 10);
remove_action('template_redirect', 'rest_output_link_header', 11);

禁用wordpress后台的健康检测

服务器健康检测应该是很多用wordpress用户现在很郁闷的地方,总是有几个改善信息,但由于种种原因没办法彻底去掉,或者不会去掉

下面就帮助各位强迫症解决这个问题

以下代码源自Site Health Tool Manager插件,添加至主题functions.php或者自己写个小插件内,后台的健康检测一下全绿

/* 屏蔽 健康检测 */
function rm_site_health( $sitehealth ) {
unset( $sitehealth['direct']['php_version'] );
unset( $sitehealth['direct']['wordpress_version'] );
unset( $sitehealth['direct']['plugin_version'] );
unset( $sitehealth['direct']['theme_version'] );
unset( $sitehealth['direct']['sql_server'] );
unset( $sitehealth['direct']['php_extensions'] );
unset( $sitehealth['direct']['php_default_timezone'] );
unset( $sitehealth['direct']['php_sessions'] );
unset( $sitehealth['direct']['utf8mb4_support'] );
unset( $sitehealth['direct']['https_status'] );
unset( $sitehealth['direct']['ssl_support'] );
unset( $sitehealth['direct']['scheduled_events'] );
unset( $sitehealth['direct']['http_requests'] );
unset( $sitehealth['direct']['is_in_debug_mode'] );
unset( $sitehealth['direct']['dotorg_communication'] );
unset( $sitehealth['direct']['background_updates'] );
unset( $sitehealth['direct']['loopback_requests'] );
unset( $sitehealth['direct']['rest_availability'] );
return $sitehealth;
}
add_filter( 'site_status_tests', 'rm_site_health' );

WordPress后台登录后过慢的绕开办法

wordpress历史各个版本中,尤其4.0以后到现在5.0的版本,登录后跳转到仪表盘(默认是/wp-admin/index.php)会非常慢。

网上很多大神都给出了各种办法,add_filter,硬改代码。但可能会发现并没有彻底解决,就算屏蔽了各种东西,仪表盘、更新等页面还是会很慢,这是因为这些页面会有很多请求很多加载项,不止load-styles,load-script这种本地加载内容。

WordPress后台登录后过慢的绕开办法
仪表盘加载7秒,CTRL+F5刷新结果

而且其实仪表盘这个页面本身如果不是一定要看WORDPRESS给的那些新闻、推送、或者使用那些快速输入等信息,并没有什么卵用……

继续阅读WordPress后台登录后过慢的绕开办法

更新说明

WordPress 4.3.1修复两个跨站点脚本漏洞补丁(cve-2015-5714,cve-2015-5715)和一个潜在的特权升级漏洞。
除了安全补丁,还修复了26处 4.3包含的错误

文件更新列表

readme.html
wp-admin/about.php
wp-admin/css/forms-rtl.css
wp-admin/css/forms.css
wp-admin/css/list-tables-rtl.css
wp-admin/css/list-tables.css
wp-admin/css/login-rtl.min.css
wp-admin/css/login.min.css
wp-admin/css/wp-admin-rtl.min.css
wp-admin/css/wp-admin.min.css
wp-admin/includes/class-wp-filesystem-ssh2.php
wp-admin/includes/class-wp-ms-users-list-table.php
wp-admin/includes/class-wp-users-list-table.php
wp-admin/includes/template.php
wp-admin/includes/upgrade.php
wp-admin/includes/user.php
wp-admin/includes/version.php
wp-admin/js/customize-controls.js
wp-admin/js/customize-controls.min.js
wp-admin/js/customize-nav-menus.js
wp-admin/js/customize-nav-menus.min.js
wp-admin/js/edit-comments.js
wp-admin/js/edit-comments.min.js
wp-admin/js/user-profile.js
wp-admin/js/user-profile.min.js
wp-admin/network/site-new.php
wp-admin/network/site-users.php
wp-admin/network/user-new.php
wp-admin/network/users.php
wp-includes/category-template.php
wp-includes/class-wp-xmlrpc-server.php
wp-includes/default-widgets.php
wp-includes/formatting.php
wp-includes/js/tinymce/plugins/charmap/plugin.js
wp-includes/js/tinymce/plugins/charmap/plugin.min.js
wp-includes/js/tinymce/plugins/lists/plugin.js
wp-includes/js/tinymce/plugins/media/plugin.js
wp-includes/js/tinymce/plugins/media/plugin.min.js
wp-includes/js/tinymce/plugins/paste/plugin.js
wp-includes/js/tinymce/plugins/paste/plugin.min.js
wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js
wp-includes/js/tinymce/plugins/wplink/plugin.js
wp-includes/js/tinymce/plugins/wplink/plugin.min.js
wp-includes/js/tinymce/plugins/wpview/plugin.js
wp-includes/js/tinymce/plugins/wpview/plugin.min.js
wp-includes/js/tinymce/skins/lightgray/content.inline.min.css
wp-includes/js/tinymce/skins/lightgray/content.min.css
wp-includes/js/tinymce/skins/lightgray/skin.ie7.min.css
wp-includes/js/tinymce/skins/lightgray/skin.min.css 
wp-includes/js/tinymce/themes/modern/theme.js
wp-includes/js/tinymce/themes/modern/theme.min.js
wp-includes/js/tinymce/tinymce.min.js 
wp-includes/js/tinymce/wp-tinymce.js.gz
wp-includes/js/wp-ajax-response.js
wp-includes/js/wp-ajax-response.min.js
wp-includes/media.php
wp-includes/pluggable.php
wp-includes/shortcodes.php
wp-includes/taxonomy.php
wp-includes/user.php
wp-includes/version.php
wp-includes/widgets.php
wp-includes/wp-db.php


继续阅读

解决WordPress后台安装主题、安装插件图片不显示的问题

平时在后台,新手喜欢到WP自带的主题、插件商店安装、搜索,但图片不显示~带来不小的麻烦~尤其页面打开速度缓慢是最大的问题。

解决办法很简单,更改本机HOSTS即可,将下面的代码,编辑到计算机%windir%\Windows\System32\drivers\etc内的HOSTS文件最后,保存即可(记事本就可以编辑保存)

注意,是没有扩展名的那个,%windir%代表你系统盘符,默认是C:

#wpCDN
93.184.216.127 s.w.org
93.184.216.127 ts.w.org
93.184.216.127 ps.w.org
#GOOGLE字体、AJAX地址解析到中国360CDN的IP
106.39.201.244 fonts.googleapis.com
125.88.190.61 libs.googleapis.com
125.88.190.61 ajax.googleapis.com

继续阅读解决WordPress后台安装主题、安装插件图片不显示的问题