AW Code のテーマ見本

AW WP Plugin シリーズ

AW Code のテーマを同じコードで見比べる見本です。上のカルーセルは代表的な 12 種、下の 3 つの枠は右上の一覧から 90 種すべてと「auto」を選べます。選んだテーマの CSS はそのときに読み込まれます。

代表的な 12 種

全 90 種から選ぶ

PHP。ファイル名のタブと行の強調付き。

first-alive.phpPHP
<?php/** * Return the first host that answers on port 22. */function first_alive( array $hosts, int $timeout = 2 ): ?string {    foreach ( $hosts as $host ) {        $fp = @fsockopen( $host, 22, $errno, $errstr, $timeout );        if ( $fp ) {            fclose( $fp );            return $host;        }    }    return null;} echo first_alive( [ 'test-node-01.example.com', 'test-node-02.example.com' ] ) ?? 'none', PHP_EOL;

Bash。

probe.shBash
#!/usr/bin/env bashset -euo pipefailfor h in test-node-01 test-node-02; do  if ping -c1 -W1 "$h.example.com" >/dev/null; then    echo "$h: up"  else    echo "$h: down" >&2  fidone

Python。行番号なし。

probe.pyPython
import asyncio async def probe(host: str, port: int = 22) -> bool:    try:        _, w = await asyncio.wait_for(asyncio.open_connection(host, port), 2)    except (OSError, asyncio.TimeoutError):        return False    w.close()    return True print(asyncio.run(probe("test-node-01.example.com")))

一覧は AW Code の製品ページ に戻って選び直せます。