essful. $this->rest_authentication_status = true; $this->rest_authentication_type = 'blog'; return null; } if ( $verified && isset( $verified['type'] ) && 'user' === $verified['type'] && ! empty( $verified['user_id'] ) ) { // User-level authentication successful. $this->rest_authentication_status = true; $this->rest_authentication_type = 'user'; return $verified['user_id']; } // Something else went wrong. Probably a signature error. $this->rest_authentication_status = new \WP_Error( 'rest_invalid_signature', __( 'The request is not signed correctly.', 'jetpack-connection' ), array( 'status' => 400 ) ); return null; } finally { $this->doing_determine_current_user_filter = false; } } /** * Report authentication status to the WP REST API. * * @param WP_Error|mixed $value Error from another authentication handler, null if we should handle it, or another value if not. * @return WP_Error|boolean|null {@see WP_JSON_Server::check_authentication} */ public function wp_rest_authentication_errors( $value ) { if ( null !== $value ) { return $value; } return $this->rest_authentication_status; } /** * Resets the saved authentication state in between testing requests. */ public function reset_saved_auth_state() { $this->rest_authentication_status = null; $this->connection_manager->reset_saved_auth_state(); } /** * Whether the request was signed with a blog token. * * @since 1.29.0 * * @return bool True if the request was signed with a valid blog token, false otherwise. */ public static function is_signed_with_blog_token() { $instance = self::init(); return true === $instance->rest_authentication_status && 'blog' === $instance->rest_authentication_type; } }