{"id":7415,"date":"2021-07-07T21:25:49","date_gmt":"2021-07-07T13:25:49","guid":{"rendered":"https:\/\/www.wopus.org\/?p=7415"},"modified":"2021-07-08T14:20:10","modified_gmt":"2021-07-08T06:20:10","slug":"%e7%a7%bb%e9%99%a4%e4%b8%8d%e9%9c%80%e8%a6%81%e7%9a%84-wordpress-%e5%a4%9a%e4%bd%99%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/wopus.org\/?p=7415","title":{"rendered":"\u79fb\u9664\u4e0d\u9700\u8981\u7684 WordPress \u591a\u4f59\u529f\u80fd"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>WordPress \u53d1\u5c55\u81f3\u4eca\uff0c\u672c\u8eab\u96c6\u6210\u4e86\u975e\u5e38\u591a\u975e\u5e38\u4e30\u5bcc\u7684\u529f\u80fd\u3002\u4f46\u662f\u4e5f\u6709\u666e\u901a\u535a\u4e3b\u4e0d\u9700\u8981\u7684\u529f\u80fd\uff0c\u6709\u4e9b\u751a\u81f3\u4f1a\u66b4\u9732 WordPress \u7a0b\u5e8f\u7684\u90e8\u5206\u4fe1\u606f\uff0c\u5b58\u5728\u5b89\u5168\u9690\u60a3\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u56fd\u5185\u7684\u5f00\u53d1\u8005\u5728\u5f00\u53d1\u65f6\u4f1a\u628a\u8fd9\u4e9b\u529f\u80fd\u5168\u90e8\u5c4f\u853d\uff0c\u4f46\u5982\u679c\u4f60\u4f7f\u7528\u7684\u4e3b\u9898\u6ca1\u6709\u63d0\u4f9b\u8fd9\u4e9b\u529f\u80fd\uff0c\u6216\u662f\u56fd\u5916\u7684\u4e3b\u9898\uff0c\u60f3\u81ea\u5df1\u4fee\u6539\uff0c\u53ef\u4ee5\u53c2\u8003\u672c\u6587\u4e0b\u9762\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u4f7f\u7528\u7f16\u8f91\u5de5\u5177\u6216\u76f4\u63a5\u5728\u670d\u52a1\u5668\u4fee\u6539\u4e3b\u9898\u7684 Function.php \u6587\u4ef6\uff0c\u5c06\u4e0b\u6587\u4e2d\u4f60\u9700\u8981\u7684\u90e8\u5206\u6dfb\u52a0\u8fdb\u53bb\u4fdd\u5b58\u5373\u53ef\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u79fb\u9664\u4fe1\u606f<\/h3>\n<p>\u79fb\u9664 WordPress \u7248\u672c\u53f7\uff1a<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action( 'wp_head', 'wp_generator' );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 RSD \u548c wlwmanifest<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action( 'wp_head', 'rsd_link' );\r\nremove_action( 'wp_head', 'wlwmanifest_link' );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 Feed<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action( 'wp_head', 'feed_links', 2 );\r\nremove_action( 'wp_head', 'feed_links_extra', 3 );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 Meta \u4e2d\u7684 Post \u4fe1\u606f<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action( 'wp_head', 'index_rel_link' ); \r\nremove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); \r\nremove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); \r\nremove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); \r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 emoji \u548c\u5bf9\u5e94\u7684 CSS<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action( 'wp_head', 'print_emoji_detection_script', 7 );\r\nremove_action( 'wp_print_styles', 'print_emoji_styles' );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 Json \u94fe\u63a5<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 Shortlink<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">remove_action('wp_head', 'wp_shortlink_wp_head'); \r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 DNSPrefetch<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">function wopus_remove_dns_prefetch( $hints, $relation_type ) {\r\n  if ( 'dns-prefetch' === $relation_type ) {\r\n    return array_diff( wp_dependencies_unique_hosts(), $hints );\r\n  }\r\n\r\n  return $hints;\r\n}\r\nadd_filter( 'wp_resource_hints', 'wopus_remove_dns_prefetch', 10, 2 );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u7981\u7528 embed\u3001REST API\u3001oEmbed \u76f8\u5173<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">function wopus_disable_embeds_init() {\r\n  global $wp;\r\n\r\n  \/\/ Remove the embed query var.\r\n  $wp-&gt;public_query_vars = array_diff( $wp-&gt;public_query_vars, array(\r\n    'embed',\r\n  ) );\r\n\r\n  \/\/ Remove the REST API endpoint.\r\n  remove_action( 'rest_api_init', 'wp_oembed_register_route' );\r\n\r\n  \/\/ Turn off\r\n  add_filter( 'embed_oembed_discover', '__return_false' );\r\n\r\n  \/\/ Don't filter oEmbed results.\r\n  remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );\r\n\r\n  \/\/ Remove oEmbed discovery links.\r\n  remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );\r\n\r\n  \/\/ Remove oEmbed-specific JavaScript from the front-end and back-end.\r\n  remove_action( 'wp_head', 'wp_oembed_add_host_js' );\r\n  add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );\r\n\r\n  \/\/ Remove all embeds rewrite rules.\r\n  add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );\r\n}\r\nadd_action( 'init', 'wopus_disable_embeds_init', 9999 );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664 wpembed TinyMCE \u63d2\u4ef6<\/p>\n<pre class=\"pure-highlightjs line-numbers\"><code class=\"language-php\">function wopus_disable_embeds_tiny_mce_plugin( $plugins ) {\r\n  return array_diff( $plugins, array( 'wpembed' ) );\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u79fb\u9664\u6240\u6709 embeds \u76f8\u5173 Rewrite \u89c4\u5219<\/p>\n<pre class=\"pure-highlightjs line-numbers\">\r\n<code class=\"language-php\">\r\n\/**\r\n *   \u79fb\u9664\u6240\u6709 embeds \u76f8\u5173 Rewrite \u89c4\u5219\r\n *\/\r\nfunction wopus_disable_embeds_rewrites( $rules ) {\r\n  foreach ( $rules as $rule =&gt; $rewrite ) {\r\n    if ( false !== strpos( $rewrite, 'embed=true' ) ) {\r\n      unset( $rules[ $rule ] );\r\n    }\r\n  }\r\n  return $rules;\r\n}\r\n\/**\r\n *   \u79fb\u9664\u63d2\u4ef6\u542f\u7528\u65f6 embeds \u76f8\u5173 Rewrite \u89c4\u5219\r\n *\/\r\nfunction wopus_disable_embeds_remove_rewrite_rules() {\r\n  add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );\r\n  flush_rewrite_rules();\r\n}\r\nregister_activation_hook( __FILE__, 'disable_embeds_remove_rewrite_rules' );\r\n\r\n\/**\r\n *   \u51b2\u6389\u63d2\u4ef6\u505c\u7528\u65f6 embeds \u76f8\u5173 Rewrite \u89c4\u5219\r\n *\/\r\nfunction wopus_disable_embeds_flush_rewrite_rules() {\r\n  remove_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );\r\n  flush_rewrite_rules();\r\n}\r\nregister_deactivation_hook( __FILE__, 'disable_embeds_flush_rewrite_rules' );\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>\u5c3e\u58f0<\/h3>\n<p>\u5982\u679c\u4e0d\u613f\u610f\u81ea\u5df1\u624b\u52a8\u4fee\u6539\u4ee3\u7801\uff0c\u4f7f\u7528\u7b2c\u4e09\u65b9\u63d2\u4ef6\u6bd4\u5982 WPJam \u4e4b\u7c7b\u7684\u4e5f\u53ef\u4ee5\u90e8\u5206\u8fbe\u6210\u8fd9\u7c7b\u79fb\u9664\u7279\u5b9a\u529f\u80fd\u7684\u9700\u6c42\u3002\u4f46\u662f\u63d2\u4ef6\u6bd5\u7adf\u662f\u522b\u4eba\u7684\uff0c\u81ea\u5df1\u7684\u4e1c\u897f\u5efa\u8bae\u81ea\u5df1\u53bb\u505a\uff0c\u6bd5\u7adf\u5b9e\u8df5\u51fa\u771f\u77e5\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 WordPress \u53d1\u5c55\u81f3\u4eca\uff0c\u672c\u8eab\u96c6\u6210\u4e86\u975e\u5e38\u591a\u975e\u5e38\u4e30\u5bcc\u7684\u529f\u80fd\u3002\u4f46\u662f\u4e5f\u6709\u666e\u901a\u535a\u4e3b\u4e0d\u9700\u8981\u7684\u529f\u80fd\uff0c\u6709\u4e9b\u751a\u81f3\u4f1a\u66b4\u9732 WordPress \u7a0b\u5e8f\u7684\u90e8\u5206\u4fe1\u606f\uff0c\u5b58\u5728\u5b89\u5168\u9690\u60a3\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u56fd\u5185\u7684\u5f00\u53d1\u8005\u5728\u5f00\u53d1\u65f6\u4f1a\u628a\u8fd9\u4e9b\u529f\u80fd\u5168\u90e8\u5c4f\u853d\uff0c\u4f46\u5982\u679c\u4f60\u4f7f\u7528\u7684\u4e3b\u9898\u6ca1\u6709\u63d0\u4f9b\u8fd9\u4e9b\u529f\u80fd\uff0c\u6216\u662f\u56fd\u5916\u7684\u4e3b\u9898\uff0c\u60f3\u81ea\u5df1\u4fee\u6539\uff0c\u53ef\u4ee5\u53c2\u8003\u672c\u6587\u4e0b\u9762\u7684\u5185\u5bb9\u3002 \u4f7f\u7528\u7f16\u8f91\u5de5\u5177\u6216\u76f4\u63a5\u5728\u670d\u52a1\u5668\u4fee\u6539\u4e3b\u9898\u7684 Function.php \u6587\u4ef6\uff0c\u5c06\u4e0b\u6587\u4e2d\u4f60\u9700\u8981\u7684\u90e8\u5206\u6dfb\u52a0\u8fdb\u53bb\u4fdd\u5b58\u5373\u53ef\u3002 &nbsp; \u79fb\u9664\u4fe1\u606f \u79fb\u9664 WordPress \u7248\u672c\u53f7\uff1a remove_action( &#8216;wp_head&#8217;, &#8216;wp_generator&#8217; ); &nbsp; \u79fb\u9664 RSD \u548c wlwmanifest remove_action( &#8216;wp_head&#8217;, &#8216;rsd_link&#8217; ); remove_action( &#8216;wp_head&#8217;, &#8216;wlwmanifest_link&#8217; ); &nbsp; \u79fb\u9664 Feed remove_action( &#8216;wp_head&#8217;, &#8216;feed_links&#8217;, 2 ); remove_action( &#8216;wp_head&#8217;, &#8216;feed_links_extra&#8217;, 3 ); &nbsp; \u79fb\u9664 Meta \u4e2d\u7684 Post \u4fe1\u606f remove_action( &#8216;wp_head&#8217;, &#8216;index_rel_link&#8217; ); remove_action( &#8216;wp_head&#8217;, [&hellip;]<\/p>\n","protected":false},"author":914,"featured_media":7427,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-7415","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/7415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/users\/914"}],"replies":[{"embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7415"}],"version-history":[{"count":4,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/7415\/revisions"}],"predecessor-version":[{"id":7436,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/7415\/revisions\/7436"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/media\/7427"}],"wp:attachment":[{"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}