添加REST重写规则。

原型

rest_api_register_rewrites()

源文件

路径:wp-includes/rest-api.php

<?php
...
function rest_api_register_rewrites() {
	global $wp_rewrite;
	add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' );
	add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' );
	add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' );
	add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/rest_api_register_rewrites/