禁用REST API、移除wp-json链接

  1. // 屏蔽 REST API
  2. remove_action('init',   'rest_api_init' );
  3. remove_action('rest_api_init', 'rest_api_default_filters', 10 );
  4. remove_action('parse_request', 'rest_api_loaded' );
  5. add_filter('rest_enabled',  '__return_false');
  6. add_filter('rest_jsonp_enabled','__return_false');
  7. // 移除头部 wp-json 标签和 HTTP header 中的 link 
  8. remove_action('wp_head',   'rest_output_link_wp_head', 10 );
  9. remove_action('template_redirect', 'rest_output_link_header', 11);
  10. remove_action('xmlrpc_rsd_apis', 'rest_output_rsd');
  11. remove_action('auth_cookie_malformed',  'rest_cookie_collect_status');
  12. remove_action('auth_cookie_expired',  'rest_cookie_collect_status');
  13. remove_action('auth_cookie_bad_username', 'rest_cookie_collect_status');
  14. remove_action('auth_cookie_bad_hash',  'rest_cookie_collect_status');
  15. remove_action('auth_cookie_valid',   'rest_cookie_collect_status');
  16. remove_filter('rest_authentication_errors', 'rest_cookie_check_errors', 100 );

相关推荐