[wp-trac] [WordPress Trac] #42973: REST endpoint points to root installation always
WordPress Trac
noreply at wordpress.org
Sun Dec 24 09:16:09 UTC 2017
#42973: REST endpoint points to root installation always
---------------------------+-----------------------------
Reporter: dingo_bastard | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.9.1
Severity: normal | Keywords:
Focuses: rest-api |
---------------------------+-----------------------------
There is a [[https://github.com/WPTRT/theme-sniffer/issues/80|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
<?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?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42973>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list