sites->current()->toArray(); } catch ( NotifyPressException $exception ) { log( 'Could not refresh the current site record', array( 'error' => $exception->getMessage() ) ); return self::cached(); } if ( empty( $site ) ) { return self::cached(); } set_transient( self::cache_key(), $site, self::CACHE_TTL ); return $site; } /** * Drop the cached record — the app's copy just changed, or is about to. * * @return void */ public static function flush(): void { delete_transient( self::cache_key() ); } /** * Cache key, scoped to the API token so reconnecting to a different * account never reuses another site's record. * * @return string */ private static function cache_key(): string { return 'notifypress_current_site_' . md5( Client::token() ); } }