()/column_default()) for LogListTable's own logic to be unit-tested * without a full WP admin bootstrap. */ class WP_List_Table { /** @var list> */ public $items = []; /** @var array{0: array, 1: list, 2: list}|null */ public $_column_headers; /** @var array */ protected $_args; /** @var array */ protected $_pagination_args = []; /** @param array $args */ public function __construct(array $args = []) { $this->_args = $args; } public function get_pagenum(): int { return isset($_GET['paged']) ? max(1, (int) $_GET['paged']) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended } /** @param array $args */ public function set_pagination_args(array $args): void { $this->_pagination_args = $args; } /** @return array */ public function pagination_args(): array { return $this->_pagination_args; } /** @return array */ public function get_columns(): array { return []; } public function single_row($item): void { echo ''; $this->single_row_columns($item); echo ''; } /** Like the real class: the per-page screen option of the current user, else the default. */ protected function get_items_per_page($option, $default_value = 20): int { $perPage = (int) get_user_option($option); return $perPage < 1 ? $default_value : $perPage; } protected function get_default_primary_column_name() { $columns = $this->get_columns(); return (string) array_key_first($columns); } /** @param array $item */ protected function single_row_columns($item): void { $primary = $this->get_default_primary_column_name(); foreach (array_keys($this->get_columns()) as $column_name) { $method = 'column_' . $column_name; $value = method_exists($this, $method) ? $this->{$method}($item) : $this->column_default($item, $column_name); $value .= $this->handle_row_actions($item, $column_name, $primary); printf('%s', $column_name, $value); } } /** Like the real class: only the mobile toggle in the primary column. */ protected function handle_row_actions($item, $column_name, $primary) { return $column_name === $primary ? $this->toggleRow() : ''; } /** @param array $actions */ protected function row_actions($actions, $always_visible = false) { if ($actions === []) { return ''; } $links = []; foreach ($actions as $action => $link) { $links[] = "{$link}"; } return '
' . implode(' | ', $links) . '
' . $this->toggleRow(); } private function toggleRow(): string { return ''; } /** @param array $item */ protected function column_default($item, $column_name): string { return ''; } public function no_items(): void { } public function prepare_items(): void { } /** Like the real class: the top table nav (with extra_tablenav()) comes before the rows. */ public function display(): void { $this->extra_tablenav('top'); } /** @param string $which */ protected function extra_tablenav($which) { } } }