Skip to content

Commit 38a1082

Browse files
committed
Merge pull request WP-API#32 from trevordevore:support-blogs-not-at-root-domain
2 parents 161b675 + d3316aa commit 38a1082

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/class-wp-json-authentication-oauth1.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,13 @@ protected function check_oauth_signature( $consumer, $oauth_params, $token = nul
551551

552552
$params = array_merge( $params, $oauth_params );
553553

554-
$base_request_uri = rawurlencode( get_home_url( null, parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ) );
554+
// Support WP blog roots that point to a folder and not just a domain
555+
$home_url_path = parse_url(get_home_url (null,''), PHP_URL_PATH );
556+
$request_uri_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
557+
if (substr($request_uri_path, 0, strlen($home_url_path)) == $home_url_path) {
558+
$request_uri_path = substr($request_uri_path, strlen($home_url_path));
559+
}
560+
$base_request_uri = rawurlencode( get_home_url( null, $request_uri_path ) );
555561

556562
// get the signature provided by the consumer and remove it from the parameters prior to checking the signature
557563
$consumer_signature = rawurldecode( $params['oauth_signature'] );

0 commit comments

Comments
 (0)