Skip to content

Commit

Permalink
Only show error for logged-out users when status is 401
Browse files Browse the repository at this point in the history
Co-authored-by: felixarntz <[email protected]>
  • Loading branch information
westonruter and felixarntz committed Jan 17, 2025
1 parent b747fd5 commit 93a51d8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/optimization-detective/site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ function od_compose_site_health_result( $response ): array {
count( $data['data']['params'] ) > 0
);
if ( ! $is_expected ) {
$result['status'] = 'recommended';
$result['label'] = __( 'The Optimization Detective REST API endpoint is unavailable to logged-out users', 'optimization-detective' );
$result['status'] = 'recommended';
if ( 401 === $code ) {
$result['label'] = __( 'The Optimization Detective REST API endpoint is unavailable to logged-out users', 'optimization-detective' );
} else {
$result['label'] = $error_label;
}
$result['description'] = $common_description_html . $error_description_html . '<p>' . wp_kses(
sprintf(
/* translators: %d is the HTTP status code, %s is the status header description */
Expand Down Expand Up @@ -251,7 +255,7 @@ function od_maybe_render_rest_api_health_check_admin_notice( bool $in_plugin_row
* @param string $plugin_file Plugin file.
*/
function od_render_rest_api_health_check_admin_notice_in_plugin_row( string $plugin_file ): void {
if ( 'optimization-detective/load.php' !== $plugin_file ) { // TODO: What if a different plugin slug is used?
if ( basename( __DIR__ ) !== dirname( $plugin_file ) ) {
return;
}
od_maybe_render_rest_api_health_check_admin_notice( true );
Expand Down

0 comments on commit 93a51d8

Please sign in to comment.