public function isApi(bool $flag = null): bool
    {
        if (isset($flag)) {
            $this->is_api = $flag;
        }
        if (!isset($this->is_api) && $this->is_wordpress) {
            if ((defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) || (defined('REST_REQUEST') && REST_REQUEST)) {
                $this->is_api = true; // Via WP constants.
            }
        }
        return (bool) $this->is_api;
    }