rocklobster-in / bogo

This is the development repository for Bogo, a straight-forward multilingual plugin for WordPress.
https://wordpress.org/plugins/bogo/
Other
24 stars 14 forks source link

The URL of the endpoint added by register_rest_route() is rewritten, resulting in a 404. #170

Closed inc2734 closed 3 years ago

inc2734 commented 3 years ago

I use my own plugin register_rest_route() to add the endpoint. https://github.com/inc2734/snow-monkey-forms/blob/master/snow-monkey-forms.php#L151-L173

It is then called using the rest_url() function. https://github.com/inc2734/snow-monkey-forms/blob/master/snow-monkey-forms.php#L102

rest_url() is using get_home_url() internally, and Bogo is rewriting the url in the home_url filter hook, so I think that's affecting it. https://github.com/takayukister/bogo/blob/caecc5ebd455b85a6562eb93f489c9757f87eacd/includes/link-template.php#L141-L145

※By the way, if the permalink setting is “Plain", the problem does not occur.

I'm not familiar with the rest api, so I may be wrong about the usage of register_rest_route() or rest_url().

However, since the Japanese page of Contact Form 7 also rewrote the endpoint and gave me a 404 error, I thought there might be a problem with Bogo, so I reported it just in case.

スクリーンショット 2021-03-26 10 40 51 スクリーンショット 2021-03-26 10 41 03
takayukister commented 3 years ago

Thanks. In the 3.5 release I intentionally dropped the rewrite rules for localized REST API routes since I thought they were not necessary and the ?lang=ja query should be used instead of /ja/.

Now I realized that the decision was a mistake. As you pointed out, rest_url() refers to the home URL, so the rewrite rules are anyway needed.

I'll revert the rewrite rules in the next release. Thanks again for the detailed report!

inc2734 commented 3 years ago

Thank you for your response!