#42973 closed defect (bug) (invalid)
REST endpoint points to root installation always
Reported by: | dingo_d | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.1 |
Component: | REST API | Keywords: | |
Focuses: | rest-api | Cc: |
Description
There is a ticket on github which shows that if a WordPress is installed in a subfolder, the rest route registered in a plugin won't work properly. I tested it on my own test server.
I have a root installation and a test installation in a test
subfolder. I installed the theme sniffer on the test installation, and when I try to run it (I've rewritten it so that it uses REST
instead of admin-ajax.php
), and the route it tries to fetch is https://mydomain/wp-json/theme-sniffer/v1/sniff-run
, when the correct route should be https://mydomain/test/wp-json/theme-sniffer/v1/sniff-run
The routes are added in the plugin like this
<?php add_action( 'rest_api_init', 'theme_sniffer_endpoint_init' ); /** * Register endpoints function * * @since 0.1.0 */ function theme_sniffer_endpoint_init() { register_rest_route( 'theme-sniffer/v1', '/sniff-run', array( 'methods' => 'POST', 'callback' => 'theme_sniffer_run_sniffer', ) ); register_rest_route( 'theme-sniffer/v1', '/individual-sniff', array( 'methods' => 'POST', 'callback' => 'theme_sniffer_individual_sniff', ) ); }
I haven't dug deeper but is this normal behavior?
Change History (3)
Note: See
TracTickets for help on using
tickets.
Ok so this is not a bug. Theme sniffer had a wrong value hardcoded in the ajax call.