*/ public static function slugs(): array { $slugs = array( // Reached by paired WordPress sites, never by an AI client. Its // route refuses anything without a signature from a paired host, // so every credential the wizard could produce for it would fail. DefaultServerSeeder::FLEET_SLUG, ); /** * Filter the servers no AI client may connect to. * * @since 0.4.6 * * @param array $slugs Excluded server slugs. */ // Cast rather than type-check: a callback may return anything, and // `(array)` is the idiom the rest of the plugin uses for exactly this // (see `ServerTypes::get_all_registered_transports`-style guards). $filtered = (array) apply_filters( self::FILTER, $slugs ); return array_values( array_unique( array_map( 'strval', $filtered ) ) ); } /** * Whether a slug names a server no AI client may connect to. * * @since 0.4.6 * * @param string $slug Server slug. */ public static function is_excluded( string $slug ): bool { return '' !== $slug && in_array( $slug, self::slugs(), true ); } /** * The same question, asked with a row id. * * Every caller but the wizard has an id rather than a slug, and resolving * it in each of them would be the duplication this class exists to avoid. * Matching stays on slug because ids differ between installs. * * An id that resolves to nothing is NOT treated as excluded: a missing * server is a different failure, and the caller's own not-found handling * gives a better message than this one could. * * @since 0.4.6 * * @param int $server_id Server row id. */ public static function is_excluded_id( int $server_id ): bool { if ( $server_id <= 0 ) { return false; } $rows = Query::instance()->query( array( 'id' => $server_id, 'number' => 1, ) ); if ( ! is_array( $rows ) || empty( $rows ) ) { return false; } $row = (array) $rows[0]; return self::is_excluded( isset( $row['server_slug'] ) ? (string) $row['server_slug'] : '' ); } /** * The refusal every caller shows, so the wording cannot drift between * five surfaces that all mean the same thing. * * @since 0.4.6 */ public static function refusal_message(): string { return __( 'That server is not one an AI client connects to, so it cannot be set up this way.', 'acrossai-mcp-manager' ); } }