feat: change log tab with filters, revision links and clear button
ChangeLog gains query()/abilities()/clear() (filters: ability, user, result, date range - all optional and additive). LogTab/LogListTable render the "Protokoll" admin tab: WP_List_Table with pagination, links to the post/attachment/nav_menu edit screen by object_type, a revision link shown only when the user may edit the revision's parent post, and a nonce+manage_options-gated "Protokoll leeren" with a JS confirmation and highlighted 'partial' rows. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! class_exists('WP_List_Table')) {
|
||||
/**
|
||||
* Minimal stand-in for wp-admin/includes/class-wp-list-table.php: just enough of the
|
||||
* real class's shape (constructor args, $items, single_row_columns dispatching to
|
||||
* column_<name>()/column_default()) for LogListTable's own logic to be unit-tested
|
||||
* without a full WP admin bootstrap.
|
||||
*/
|
||||
class WP_List_Table
|
||||
{
|
||||
/** @var list<array<string, mixed>> */
|
||||
public $items = [];
|
||||
|
||||
/** @var array{0: array<string, string>, 1: list<string>, 2: list<string>}|null */
|
||||
public $_column_headers;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
protected $_args;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
protected $_pagination_args = [];
|
||||
|
||||
/** @param array<string, mixed> $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<string, mixed> $args */
|
||||
public function set_pagination_args(array $args): void
|
||||
{
|
||||
$this->_pagination_args = $args;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function pagination_args(): array
|
||||
{
|
||||
return $this->_pagination_args;
|
||||
}
|
||||
|
||||
/** @return array<string, string> */
|
||||
public function get_columns(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function single_row($item): void
|
||||
{
|
||||
echo '<tr>';
|
||||
$this->single_row_columns($item);
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $item */
|
||||
protected function single_row_columns($item): void
|
||||
{
|
||||
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);
|
||||
printf('<td class="%s">%s</td>', $column_name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $item */
|
||||
protected function column_default($item, $column_name): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function no_items(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function prepare_items(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function display(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user