Admin tables: scroll containers and phone cards; Alerts list flags missing media
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
afa768fa42
commit
fb200594ce
8 files changed
+190
-54
No files matched your search
@@ -175,6 +175,33 @@ final class Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a table inside a keyboard-focusable scroll region. $headers is a list of column labels (an empty
|
||||
* label is a visually hidden column). $cards=true turns rows into labelled cards on phones (cells need
|
||||
* td() labels); false keeps sideways scrolling and shows a swipe hint on phones.
|
||||
*
|
||||
* @param string[] $headers
|
||||
*/
|
||||
public static function tableOpen( array $headers, string $label, bool $cards = true ): string {
|
||||
$h = static fn( string $s ): string => htmlspecialchars( $s, ENT_QUOTES, 'UTF-8' );
|
||||
$out = $cards ? '' : '<p class="sg-swipe-hint">Swipe sideways to see more</p>';
|
||||
$out .= '<div class="sg-scroll' . ( $cards ? ' sg-scroll-cards' : '' ) . '" tabindex="0" role="region" aria-label="' . $h( $label ) . '">';
|
||||
$out .= '<table class="widefat striped sg-table' . ( $cards ? ' sg-cards' : '' ) . '"><thead><tr>';
|
||||
foreach ( $headers as $t ) {
|
||||
$out .= '' === $t ? '<th><span class="screen-reader-text">Actions</span></th>' : '<th>' . $h( $t ) . '</th>';
|
||||
}
|
||||
return $out . '</tr></thead><tbody>';
|
||||
}
|
||||
|
||||
public static function tableClose(): string {
|
||||
return '</tbody></table></div>';
|
||||
}
|
||||
|
||||
/** Opening <td> carrying the column label that phone cards print before the value. */
|
||||
public static function td( string $label, string $class = '' ): string {
|
||||
return '<td' . ( '' !== $class ? ' class="' . htmlspecialchars( $class, ENT_QUOTES, 'UTF-8' ) . '"' : '' ) . ' data-label="' . htmlspecialchars( $label, ENT_QUOTES, 'UTF-8' ) . '">';
|
||||
}
|
||||
|
||||
public static function close(): void {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user