- Status
- Resolved
- Resolved in
- WPML 4.9
- Topic tags
- Bug
Overview of the issue
Some users set up their sites to block REST API requests that are not authenticated.
In that case you may find WPML reports that the site does not meet minimum requirements because a test REST API endpoint is not reachable, and the warning banners on the WPML > Support page and in the WPML admin toolbar dropdown cannot be dismissed.
Workaround
Until this is fixed the notice can be removed by editing the file sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/SharedKernel/Server/Application/WordPressRestApiStatus.php
Locate these lines (from line 70):
// Add basic authentication if present
if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
$args['headers']['Authorization'] =
'Basic ' . base64_encode( $_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW'] );
}
then immediately afterwards add these 2 lines:
// Add authentication from cookies
$args['cookies'] = $_COOKIE;
That will add the necessary authentication to the request which tests the REST API.