From 4a94eae87707cf35abe3ab4a11700096f82da44b Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 21 Sep 2023 09:04:51 +0200 Subject: [PATCH] add path to route (#438) * add path to route fix #421 * added changelog entry --- README.md | 7 ++++--- includes/class-signature.php | 9 +++++++++ readme.txt | 7 ++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bdbfb9c..66f6219 100644 --- a/README.md +++ b/README.md @@ -107,9 +107,10 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu ### Next ### -* Compatibility: allow deactivating blocks registered by the plugin. -* Compatibility: avoid Fatal Errors when using ClassicPress. -* Fixed: fix a typo in a hook name. +* Compatibility: allow deactivating blocks registered by the plugin +* Compatibility: avoid Fatal Errors when using ClassicPress +* Fixed: fix a typo in a hook name +* Fixed: a problem with signatures when running WordPress in a sub-path ### 1.0.0 ### diff --git a/includes/class-signature.php b/includes/class-signature.php index 1b29d4c..10cbf39 100644 --- a/includes/class-signature.php +++ b/includes/class-signature.php @@ -238,6 +238,15 @@ class Signature { } else { $route = '/' . rest_get_url_prefix() . '/' . ltrim( $request->get_route(), '/' ); } + + // fix route for subdirectory installs + $path = wp_parse_url( get_home_url(), PHP_URL_PATH ); + $path = trim( $path, '/' ); + + if ( $path ) { + $route = '/' . $path . $route; + } + $headers = $request->get_headers(); $headers['(request-target)'][0] = strtolower( $request->get_method() ) . ' ' . $route; } else { diff --git a/readme.txt b/readme.txt index 9f1fed6..f9303c3 100644 --- a/readme.txt +++ b/readme.txt @@ -107,9 +107,10 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu = Next = -* Compatibility: allow deactivating blocks registered by the plugin. -* Compatibility: avoid Fatal Errors when using ClassicPress. -* Fixed: fix a typo in a hook name. +* Compatibility: allow deactivating blocks registered by the plugin +* Compatibility: avoid Fatal Errors when using ClassicPress +* Fixed: fix a typo in a hook name +* Fixed: a problem with signatures when running WordPress in a sub-path = 1.0.0 =