WordPress 5.9 版本后对块编辑器做了深度的升级,所以导致子凡只使用经典编辑器的情况下又出现了许多的冗余代码,头部内联样式 global-styles-inline-css 和底部 duotone svg 图标的代码对于很多主题来说其实都不大兼容。
WordPress
子凡我是绝对不能够忍受页面前端出现没有仍和功能的代码。经过一番折腾,现在将成果分享一下。
移除顶部内联样式 global-styles-inline-css
将以下代码复制添加到当前 WordPress 主题的 functions.php 文件中即可
1 2 3 4 5 6 | //WordPress 移除头部 global-styles-inline-css add_action( 'wp_enqueue_scripts' , 'fanly_remove_global_styles_inline' ); function fanly_remove_global_styles_inline(){ wp_deregister_style( 'global-styles' ); wp_dequeue_style( 'global-styles' ); } |
当然如果还发现有 wp-block 相关的冗余代码,可以使用如下代码:
1 2 3 4 5 6 7 8 | add_action( 'wp_enqueue_scripts' , 'fanly_remove_styles_inline' ); function fanly_remove_styles_inline(){ wp_deregister_style( 'global-styles' ); wp_dequeue_style( 'global-styles' ); wp_dequeue_style( 'wp-block-library' ); wp_dequeue_style( 'wp-block-library-theme' ); wp_dequeue_style( 'wc-block-style' ); } |
移除底部 duotone svg 图标
在当前 WordPress 主题文件夹下添加 theme.json 文件,文件内容如下
1 2 3 4 5 6 7 8 | { "version" : 1, "setting" : { "color" : { "duotone" : null } } } |