正在查看 2 条回复
-
作者帖子
-
-
2020年12月17日 - 下午3:56 #1297
117206687
参与者网络收集!!!!!!!!!!!!!!!!! //2-删除表情脚本 remove_action( 'admin_print_scripts', 'print_emoji_detection_script'); remove_action( 'admin_print_styles', 'print_emoji_styles'); remove_action( 'wp_head', 'print_emoji_detection_script', 7); remove_action( 'wp_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'); //3-页面链接添加html后缀(有的主题默认) add_action('init', 'html_page_permalink', -1); function html_page_permalink() { global $wp_rewrite; if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')) { $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html'; } } //4-首页禁止wp-block-library(古腾堡编辑器,下面是用的页面主页) add_action( 'wp_print_styles', 'wpblocklibrary', 100 ); function wpblocklibrary() { if ( is_page('home') ) { wp_deregister_style( 'wp-block-library' ); wp_deregister_style( 'wp-block-library-theme' ); } } //5-禁用XML-RPC(第三方接口) add_filter('xmlrpc_enabled', '__return_false'); //6-禁用REST API(有的主题需要调用) add_filter('rest_enabled', '_return_false'); add_filter('rest_jsonp_enabled', '_return_false'); add_filter( 'rest_authentication_errors', function( $access ) { return new WP_Error( 'rest_cannot_acess', 'REST API已关闭', array( 'status' => 403 ) ); }); //7-禁止加载wp-embed.min.js(有的主题需要调用) function my_deregister_scripts(){ wp_dequeue_script( 'wp-embed' ); } add_action( 'wp_footer', 'my_deregister_scripts' ); //8-除后台之外删除静态资源的查询字符串 function j_remove_script_version( $src ) { $parts = explode( '?ver', $src ); return $parts[0]; } add_filter( 'script_loader_src', 'j_remove_script_version', 15, 1 ); add_filter( 'style_loader_src', 'j_remove_script_version', 15, 1 ); //9-js和cssver参数 if(!function_exists('cwp_remove_script_version')) { function cwp_remove_script_version( $src ) { return remove_query_arg( 'ver', $src ); } add_filter( 'script_loader_src', 'cwp_remove_script_version' ); add_filter( 'style_loader_src', 'cwp_remove_script_version' ); } //10-禁用auto-embeds加载外链视频封面 remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); //11-禁用feed function disable_feed() { wp_die( '本站不提供feed。<script>location.href="'.bloginfo('url').'";</script>' ); } add_action('do_feed', 'disable_feed', 1); add_action('do_feed_rdf', 'disable_feed', 1); add_action('do_feed_rss', 'disable_feed', 1); add_action('do_feed_rss2', 'disable_feed', 1); add_action('do_feed_atom', 'disable_feed', 1); //12-取消内容转义 $qmr_work_tags = array( 'the_title', // 标题 'the_content', // 内容 * 'the_excerpt', // 摘要 * 'single_post_title', // 单篇文章标题 'comment_author', // 评论作者 'comment_text', // 评论内容 * 'bloginfo', // 博客信息 'wp_title', // 网站标题 'term_description', // 项目描述 'category_description', // 分类描述 'widget_title', // 小工具标题 'widget_text' // 小工具文本 ); foreach ( $qmr_work_tags as $qmr_work_tag ) { remove_filter ($qmr_work_tag, 'wptexturize'); } /*13-整体移除页面还会显示的*/ // 移除 REST API 端点 remove_action( 'rest_api_init', 'wp_oembed_register_route' ); // 禁用 oEmbed 自动发现功能 add_filter( 'embed_oembed_discover', '__return_false' ); // 不要过滤 oEmbed 结果 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); // 移除 oEmbed 发现链接 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // 移除 oEmbed 使用的 JavaScript 文件 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); //移除加载 remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); //移除WordPress版本 remove_action( 'wp_head', 'wp_generator' ); //去除评论feed remove_action( 'wp_head', 'feed_links_extra', 3 ); //去除文章feed remove_action( 'wp_head', 'feed_links', 2 ); //屏蔽API产生的信息 remove_action( 'template_redirect', 'rest_output_link_header', 11 ); //屏蔽rel=shortlink信息 remove_action( 'template_redirect','wp_shortlink_header', 11, 0); //离线编辑器接口 remove_action( 'wp_head', 'rsd_link' ); //Windows Live Writer接口 remove_action( 'wp_head', 'wlwmanifest_link' ); //移除当前页面的索引 remove_action( 'wp_head', 'index_rel_link' ); //移除后面文章的url remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); //移除最开始文章的url remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); //自动生成的短链接 remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); //移除相邻文章的url remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // 移除检查当前页面的检测(以下也可以不用加) remove_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); remove_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); /*整体移除页面还会显示的 end*/ //14-移除comment-reply.min.js(如果不用评论) function crunchify_clean_header_hook() { wp_deregister_script( 'comment-reply' ); } add_action('init','crunchify_clean_header_hook'); //15-移除jquery-migrate.min.js(兼容老jquery库,有的主题默认不启用) function isa_remove_jquery_migrate( &$scripts ) { if( !is_admin() ) { $scripts->remove( 'jquery' ); $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' ); } } add_filter( 'wp_default_scripts', 'isa_remove_jquery_migrate' ); //16-禁用cron(定时任务) define('DISABLE_WP_CRON', true); //17-文章修订(建议还是保留不用全部关闭) define('AUTOSAVE_INTERVAL', 300); // 时间间隔 define('WP_POST_REVISIONS', false); //限制数量 define('AUTOSAVE_INTERVAL', 300); // 时间间隔 define('WP_POST_REVISIONS', 2);//修订2次 define('EMPTY_TRASH_DAYS', 3);//3天后自动清空 //18-彻底禁用Pingback与Trackback add_filter('wp_headers', function($headers, $wp_query){ if(isset($headers['X-Pingback'])){ unset($headers['X-Pingback']); } return $headers; }, 11, 2); add_filter('pre_option_enable_xmlrpc', function($state){ return '0'; }); add_action('wp', function(){ remove_action('wp_head', 'rsd_link'); }, 9); add_filter('bloginfo_url', function($output, $property){ return ($property == 'pingback_url') ? null : $output; }, 11, 2); add_action('xmlrpc_call', function($method){ if($method != 'pingback.ping') return; wp_die( 'Pingback functionality is disabled on this Blog.', 'Pingback Disabled!', array('response' => 403) ); }); //19-删除XFN (XHTML Friends Network) Profile 链接 和 Pingback URL <link rel="profile" href="http://gmpg.org/xfn/11"> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"> //找到header.php删了就行 /*后台优化*/ //20-禁用后台右上角帮助 add_action('in_admin_header', function(){ global $current_screen; $current_screen->remove_help_tabs(); }); //21-禁用后台右上角选项 add_action('in_admin_header', function(){ add_filter('screen_options_show_screen', '__return_false'); add_filter('hidden_columns', '__return_empty_array'); }); //22-禁用Admin Bar(登录之后顶部栏) add_filter( 'show_admin_bar', '__return_false' ); //23-屏蔽后台页脚WordPress版本信息 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); //24-隐藏后台标题中的“—— WordPress” add_filter('admin_title', 'zm_custom_admin_title', 10, 2); function zm_custom_admin_title($admin_title, $title){ return $title.' ‹ '.get_bloginfo('name'); } //25-隐藏登录页面标题中的“WordPress” add_filter('login_title', 'zm_custom_login_title', 10, 2); function zm_custom_login_title($login_title, $title){ return $title.' ‹ '.get_bloginfo('name'); } //26-隐藏左上角WordPress标志 function hidden_admin_bar_remove() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); } add_action('wp_before_admin_bar_render', 'hidden_admin_bar_remove', 0); //27-隐藏后台状态 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'); //其它新闻 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'); //链入插件 remove_meta_box('dashboard_quick_press', 'dashboard', 'core'); //快速发布 remove_meta_box( 'dashboard_activity', 'dashboard', 'normal'); // 动态 } add_action('admin_menu', 'disable_dashboard_widgets');
-
2020年12月17日 - 下午4:08 #1302
孙锡源
管理员emmm,看到你认真整理了这么多,我真的很不好意思说这个提议不会被采纳……
WP-China-Yes插件定位是解决WordPress在国内的本土化问题,并不是“速度优化”,功能开发秉承的原则是:
- 本土化刚需(比如翻译优化以及依赖的各种外部服务的网络优化)
- 绝大部分用户需要
争取让这个插件开箱即用,包含的功能刚好是用户需要的,不多也不少。类似WordPress功能裁剪、速度优化这类功能其实是不符合以上两个原则的。没必要把一个插件搞的大而全嘛,一个插件专注解决一个问题,随着插件功能增多,为了保证其通用性,代码量其实是指数级增长的,这会增大用户站点的负担以及出现BUG的可能性。而且对WordPress核心功能裁剪很容易导致依赖其的插件、主题报错,这对小白用户来讲是致命的。
将来如果需要搞这些功能,应该会单独另开发一个项目,而不会集成到WP-China-Yes里。
最后衷心的感谢你的支持与提议
-
2020年12月18日 - 下午8:38 #1313
快乐的客户
参与者第一、您要求添加的这些功能不应当是“WP-China-Yes”插件应该做的。您应该安装专门的WordPress优化插件。“WP-China-Yes”插件的定位是:1、中文翻译:2、网络加速。
第二、建议您对WordPress的核心功能进行设置之前,对网站进行备份。这样出现了你无法解决的故障时一键还原便是了。
-
-
作者帖子
正在查看 2 条回复
- 哎呀,回复话题必需登录。