diff --git a/lib/class-wp-rest-url-details-controller.php b/lib/class-wp-rest-url-details-controller.php index ee7c1b23a05c71..f0fbae54f54810 100644 --- a/lib/class-wp-rest-url-details-controller.php +++ b/lib/class-wp-rest-url-details-controller.php @@ -191,8 +191,19 @@ public function permissions_check() { * @return string|WP_Error The HTTP response from the remote URL, or an error. */ private function get_remote_url( $url ) { + + // Provide a modified UA string to workaround web properties which block WordPress "Pingbacks". + // Why? The UA string used for pingback requests contains `WordPress/` which is very similar + // to that used as the default UA string by the WP HTTP API. Therefore requests from this + // REST endpoint are being unintentionally blocked as they are misidentified as pingback requests. + // By slightly modifying the UA string, but still retaining the "WordPress" identification (via "WP") + // we are able to work around this issue. + // Example UA string: `WP-URLDetails/5.9-alpha-51389 (+http://localhost:8888)`. + $modified_user_agent = 'WP-URLDetails/' . get_bloginfo( 'version' ) . ' (+' . get_bloginfo( 'url' ) . ')'; + $args = array( 'limit_response_size' => 150 * KB_IN_BYTES, + 'user-agent' => $modified_user_agent, ); /**