*/ public static function slugs(): array { return array( DefaultServerSeeder::SLUG, // Back under protection since 0.3.6, having been dropped in F090 // when the row stopped being seeded. The plugin manages it again, // so the guard applies again — a protected row the seeder would // only recreate on the next admin request is a confusing delete. DefaultServerSeeder::ACROSSAI_SLUG, // Seeded, so protected on the same grounds. Protection also hides // the Danger Zone and Update Server tabs, which is right here for // a second reason: the route and slug are what paired hubs call, // so letting them be edited would break every connection silently. // Severing a fleet is "remove the host", not "rename the server". DefaultServerSeeder::FLEET_SLUG, ); } /** * Whether a slug belongs to a plugin-managed row. * * @param string $slug Server slug. * @return bool */ public static function is_protected( string $slug ): bool { return '' !== $slug && in_array( $slug, self::slugs(), true ); } /** * Whether a server array belongs to a plugin-managed row. * * Accepts both key shapes in circulation: `server_slug` (Row::to_array(), * used by the server-edit screen and the tab Registry) and `slug` * (MCPServerListTable::prepare_items()'s remapped item). * * @param array $server Server row array. * @return bool */ public static function is_protected_server( array $server ): bool { $slug = (string) ( $server['server_slug'] ?? $server['slug'] ?? '' ); return self::is_protected( $slug ); } /** * Whether a server primary key belongs to a plugin-managed row. * * For the action handlers, which only receive an id. A missing row is not * protected — the caller's own not-found handling takes over. * * @param int $server_id Server primary key. * @return bool */ public static function is_protected_id( int $server_id ): bool { if ( $server_id <= 0 ) { return false; } $rows = Query::instance()->query( array( 'id' => $server_id, 'number' => 1, ) ); if ( empty( $rows ) ) { return false; } return self::is_protected( (string) $rows[0]->server_slug ); } /** * Whether a slug is the one server surfaced as "Recommended". * * Drives both the ordering that pins that row first (servers list and * Quick Connect Step 1) and the Recommended badge in the list, the * Overview tab and the wizard card. * * This is a DIFFERENT predicate from `is_protected()` above, which covers * both seeded slugs and guards deletion rather than singling one out for * prominence. Changing which server is recommended is changing the slug * returned here — plus its mirror in Step1_ServerPick.jsx. * * @param string $slug Server slug. * @return bool */ public static function is_recommended( string $slug ): bool { return DefaultServerSeeder::ACROSSAI_SLUG === $slug; } /** * Pre-escaped "Recommended" pill markup. * * @return string */ public static function recommended_badge(): string { return sprintf( '%s', esc_html__( 'Recommended', 'acrossai-mcp-manager' ) ); } }