首页
关于
留言
Search
1
红米 AX3000 (AX6) 路由器解锁 SSH 教程
6,676 阅读
2
网盘挂载程序sharelist美化教程
4,216 阅读
3
小米路由器 AX3600 开启SSH教程,官方固件即可安装 ShellClash开启科学上网
2,168 阅读
4
Oracle 甲骨文 ARM VPS 自动抢购脚本
1,819 阅读
5
编译带PassWall和SSR-plus插件的Openwrt系统
1,393 阅读
前端
Vue
React
后端
Java
Python
PHP
数据库
运维
杂谈
小程序
影视资源
登录
Search
标签搜索
Java
Linux
Mysql
IDEA
Debian
Docker
Springboot
CentOS
Cloudflare
Maven
JavaScript
SQL
Wordpress
宝塔
Nginx
Windows
MacBook
JS
CSS
Openwrt
William
累计撰写
144
篇文章
累计收到
702
条评论
首页
栏目
前端
Vue
React
后端
Java
Python
PHP
数据库
运维
杂谈
小程序
影视资源
页面
关于
留言
搜索到
1
篇与
的结果
2021-03-02
WordPress的一些优化代码
把下面的代码放进主题的 functions.php 最下面:/*-----------------------------------------------------------------------------------*/ /* Disable the emoji's /*-----------------------------------------------------------------------------------*/ function disable_emojis() { remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); //add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); } add_action( 'init', 'disable_emojis' ); /** * Filter function used to remove the tinymce emoji plugin. * * @param array $plugins * @return array Difference betwen the two arrays */ function disable_emojis_tinymce( $plugins ) { if ( is_array( $plugins ) ) { return array_diff( $plugins, array( 'wpemoji' ) ); } else { return array(); } } /*-----------------------------------------------------------------------------------*/ /* 去除头部菜单 /*-----------------------------------------------------------------------------------*/ add_filter( 'show_admin_bar', '__return_false' ); /*-----------------------------------------------------------------------------------*/ /* 去除头部冗余代码 /*-----------------------------------------------------------------------------------*/ remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'wp_generator' ); //隐藏wordpress版本 remove_filter('the_content', 'wptexturize'); //取消标点符号转义 remove_action('rest_api_init', 'wp_oembed_register_route'); remove_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); remove_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); remove_action('wp_head', 'wp_oembed_add_discovery_links'); remove_action('wp_head', 'wp_oembed_add_host_js'); // Remove the Link header for the WP REST API // [link] => <http://cnzhx.net/wp-json/>; rel="https://api.w.org/" remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); /*-----------------------------------------------------------------------------------*/ /* 去除谷歌字体 /*-----------------------------------------------------------------------------------*/ function coolwp_remove_open_sans_from_wp_core() { wp_deregister_style( 'open-sans' ); wp_register_style( 'open-sans', false ); wp_enqueue_style('open-sans',''); } add_action( 'init', 'coolwp_remove_open_sans_from_wp_core' ); /*-----------------------------------------------------------------------------------*/ /* 修改后台字体 /*-----------------------------------------------------------------------------------*/ function admin_lettering(){ echo'<style type="text/css"> body{ font-family: Microsoft YaHei;} </style>'; } add_action('admin_head', 'admin_lettering'); /*-----------------------------------------------------------------------------------*/ /* Gravatar头像使用中国服务器 /*-----------------------------------------------------------------------------------*/ function ea_change_avatar_v2ex( $avatar ) { $avatar = preg_replace("/https:\/\/(secure|\d).gravatar.com\/avatar\//","https://dn-qiniu-avatar.qbox.me/robohash/",$avatar); return $avatar; } add_filter('get_avatar', 'ea_change_avatar_v2ex'); /*-----------------------------------------------------------------------------------*/ /* 阻止站内文章互相Pingback /*-----------------------------------------------------------------------------------*/ function theme_noself_ping( &$links ) { $home = get_option( 'home' ); foreach ( $links as $l => $link ) if ( 0 === strpos( $link, $home ) ) unset($links[$l]); } add_action('pre_ping','theme_noself_ping'); /*-----------------------------------------------------------------------------------*/ /* 删除后台某些版权和链接@wpdx /*-----------------------------------------------------------------------------------*/ add_filter('admin_title', 'wpdx_custom_admin_title', 10, 2); function wpdx_custom_admin_title($admin_title, $title){ return $title.' ‹ '.get_bloginfo('name'); } /*-----------------------------------------------------------------------------------*/ /* 去掉wordpress logo /*-----------------------------------------------------------------------------------*/ function remove_logo($wp_toolbar) { $wp_toolbar->remove_node('wp-logo'); } add_action('admin_bar_menu', 'remove_logo', 999); /*-----------------------------------------------------------------------------------*/ /* 去掉wp版权 /*-----------------------------------------------------------------------------------*/ function change_footer_admin () {return '';} add_filter('admin_footer_text', 'change_footer_admin', 9999); function change_footer_version() {return '';} add_filter( 'update_footer', 'change_footer_version', 9999); /*-----------------------------------------------------------------------------------*/ /* 去掉挂件 /*-----------------------------------------------------------------------------------*/ function disable_dashboard_widgets() { //remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');//近期评论 //remove_meta_box('dashboard_recent_drafts', 'dashboard', 'normal');//近期草稿 remove_meta_box('dashboard_primary', 'dashboard', 'core');//wordpress博客 remove_meta_box('dashboard_secondary', 'dashboard', 'core');//wordpress其它新闻 remove_meta_box('dashboard_right_now', 'dashboard', 'core');//wordpress概况 //remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');//wordresss链入链接 //remove_meta_box('dashboard_plugins', 'dashboard', 'core');//wordpress链入插件 //remove_meta_box('dashboard_quick_press', 'dashboard', 'core');//wordpress快速发布 } add_action('admin_menu', 'disable_dashboard_widgets'); /*-----------------------------------------------------------------------------------*/ /* 去掉无用小工具 /*-----------------------------------------------------------------------------------*/ function unregister_default_widgets() { unregister_widget( 'WP_Widget_Pages' ); unregister_widget( 'WP_Widget_Calendar' ); unregister_widget( 'WP_Widget_Meta' ); unregister_widget( 'WP_Widget_Search' ); unregister_widget( 'WP_Widget_Categories' ); unregister_widget( 'WP_Widget_Recent_Posts' ); unregister_widget( 'WP_Widget_Recent_Comments' ); unregister_widget( 'WP_Widget_RSS' ); } add_action("widgets_init", "unregister_default_widgets", 11);
2021年03月02日
21 阅读
0 评论
0 点赞