$extra Same as for html(). */ public static function css( array $extra = array() ): string { $colours = array(); foreach ( MaintenanceConfig::COLOURS as $key => $fallback ) { $value = isset( $extra[ $key ] ) ? (string) $extra[ $key ] : ''; $colours[ $key ] = 1 === preg_match( '/^#[0-9a-fA-F]{6}$/', $value ) ? $value : $fallback; } $image = isset( $extra['image'] ) ? (string) $extra['image'] : ''; $style = self::image_style( $extra ); $css = ':root{--fxd-bg:' . $colours['color_background'] . ';--fxd-box:' . $colours['color_box'] . ';--fxd-text:' . $colours['color_text'] . ';--fxd-accent:' . $colours['color_accent'] . '}' . '*{box-sizing:border-box}body{margin:0;min-height:100vh;display:flex;flex-direction:column;background:var(--fxd-bg);color:var(--fxd-text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}' . '.fxd-wrap{flex:1;display:flex;align-items:center;justify-content:center;padding:2rem 1rem}' . 'main{width:100%;max-width:34rem;padding:2.5rem;background:var(--fxd-box);border-radius:12px;box-shadow:0 2px 16px rgba(0,0,0,.08);text-align:center}' . '.fxd-logo{display:block;max-width:220px;max-height:90px;width:auto;height:auto;margin:0 auto 1.5rem}' . 'h1{margin:0 0 1rem;font-size:1.8rem;line-height:1.25}p{margin:0;line-height:1.6;font-size:1.05rem}' . 'a{color:var(--fxd-accent)}' . 'footer{display:flex;flex-wrap:wrap;gap:.5rem 1.25rem;justify-content:center;padding:1rem;font-size:.85rem}footer a{color:inherit;opacity:.8}' . '.fxd-extra{margin-top:1.75rem;text-align:left}' . '.fxd-extra input:not([type=checkbox]):not([type=radio]),.fxd-extra textarea,.fxd-extra select{width:100%;padding:.6rem;border:1px solid rgba(0,0,0,.25);border-radius:6px;font:inherit}' . '.fxd-extra button,.fxd-extra input[type=submit]{background:var(--fxd-accent);color:#fff;border:0;border-radius:6px;padding:.7rem 1.4rem;font:inherit;cursor:pointer}' . '.fxd-extra label{display:block;margin:.75rem 0 .25rem;font-weight:600}'; if ( MaintenanceConfig::IMAGE_BACKGROUND === $style ) { $css .= 'body{background:var(--fxd-bg) url("' . esc_url( $image ) . '") center/cover no-repeat fixed}'; } elseif ( MaintenanceConfig::IMAGE_SIDE === $style ) { $css .= '.fxd-split{flex:1;display:grid;grid-template-columns:1fr 1fr}.fxd-side{background:url("' . esc_url( $image ) . '") center/cover no-repeat;min-height:40vh}' . '@media(max-width:780px){.fxd-split{grid-template-columns:1fr}}'; } return $css; } /** * The image layout that applies: none when there is no image. * * @param array $extra Same as for html(). */ private static function image_style( array $extra ): string { $image = isset( $extra['image'] ) ? (string) $extra['image'] : ''; return '' === $image ? MaintenanceConfig::IMAGE_NONE : (string) ( $extra['image_style'] ?? MaintenanceConfig::IMAGE_NONE ); } /** * The HTML document. * * @param string $site Site name. * @param string $title Heading. * @param string $message Text, line breaks are kept. * @param string $lang Language code. * @param bool $noindex Whether search engines are told to skip the page. * @param array $extra Optional look and parts: logo and image (URLs), image_style, * the colours of MaintenanceConfig::COLOURS, legal (label => URL), * styles (the printed style queue, see MaintenanceApp), * and head / after (HTML from add-ons, already escaped). */ public static function html( string $site, string $title, string $message, string $lang, bool $noindex, array $extra = array() ): string { $logo = isset( $extra['logo'] ) ? (string) $extra['logo'] : ''; $style = self::image_style( $extra ); $box = '
' . ( '' !== $logo ? '' : '' ) . '

' . esc_html( $title ) . '

' . nl2br( esc_html( $message ) ) . '

' . (string) ( $extra['after'] ?? '' ) . '
'; $links = ''; foreach ( (array) ( $extra['legal'] ?? array() ) as $label => $url ) { $links .= '' . esc_html( (string) $label ) . ''; } $footer = '' !== $links ? '
' . $links . '
' : ''; $body = MaintenanceConfig::IMAGE_SIDE === $style ? '
' . $box . '
' : '
' . $box . '
'; return '' . '' . ( $noindex ? '' : '' ) . '' . esc_html( $title . ' - ' . $site ) . '' . (string) ( $extra['styles'] ?? '' ) . (string) ( $extra['head'] ?? '' ) . '' . $body . $footer . ''; } }