query_vars['rest_route'], '/' ); if ( false !== strpos( $route, 'altcha/v1' ) || false !== strpos( $route, 'contact-form-7/v1' ) ) { $allow_rest_api_access = true; } else { $allow_rest_api_access = false; } } else { $allow_rest_api_access = true; } if ( !$allow_rest_api_access ) { return new WP_Error('rest_api_authentication_required', 'The REST API has been restricted to authenticated users.', array( 'status' => rest_authorization_required_code(), )); } } }