WordPress 5.2.4
I'm trying to get valid HTML.
A validator (https://validator.w3.org/ ) shows this:
Error: Bad value https://api.w.org/ for attribute rel on element link: The string https://api.w.org/ is not a registered keyword.
From line 135, column 1; to line 135, column 60
?https://api.w.org/' href='http://ved/wp-json/' />?
The problem seems to be in wp-includes/rest-api.php, line 841:
function rest_output_link_wp_head() {
$api_root = get_rest_url();
if ( empty( $api_root ) ) {
return;
}
echo "<link rel='https://api.w.org/' href='" . esc_url( $api_root ) . "' />\n"; // Line 841.
}
Run Code Online (Sandbox Code Playgroud)
Well, this seems to be the core of WordPress. But it renders invalid code.
Cold you help me with these two questions: 1. What is the most correct and elegant way to cope with this problem? 2. Is there anything that should be taken into consdideration here. I mean that I don't seem to be going to use REST API, but maybe some plugins need REST API.
小智 5
// Disable REST API link tag
remove_action('wp_head', 'rest_output_link_wp_head', 10);
// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
Run Code Online (Sandbox Code Playgroud)
尝试在function.php中添加上面的代码
| 归档时间: |
|
| 查看次数: |
1457 次 |
| 最近记录: |