From b7d5016b3a486b6d758855a79763353408d6b5ec Mon Sep 17 00:00:00 2001 From: Nika Siradze Date: Tue, 30 Jun 2026 17:18:09 +0400 Subject: [PATCH] Merge Activity into Dashboard as a tab (Overview / Activity) - Dashboard is now tabbed; the standalone Activity menu item is gone. - Activity view + dashboard view stripped of their own page chrome; the controller provides the wrap, header, and tab nav. #aggregate-it-app preserved on Overview so the dashboard JS still runs (and cleanly bails on the Activity tab). - Activity links/forms/pagination point at ?page=aggregate-it&tab=activity. --- src/Admin/Admin.php | 78 ++++++++++++++++++++--------------- src/Admin/views/activity.php | 14 +++---- src/Admin/views/dashboard.php | 7 +--- src/Admin/views/entities.php | 2 +- 4 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/Admin/Admin.php b/src/Admin/Admin.php index 12d3d40..e24037f 100644 --- a/src/Admin/Admin.php +++ b/src/Admin/Admin.php @@ -120,15 +120,6 @@ public function menu(): void { [ $this, 'render_entities' ] ); - $this->hooks[] = add_submenu_page( - self::SLUG, - __( 'Activity', 'aggregate-it' ), - __( 'Activity', 'aggregate-it' ), - 'manage_options', - self::SLUG . '-activity', - [ $this, 'render_activity' ] - ); - $this->hooks[] = add_submenu_page( self::SLUG, __( 'Settings', 'aggregate-it' ), @@ -176,9 +167,17 @@ public function assets( string $hook ): void { } public function render_dashboard(): void { - $s = $this->plugin->settings(); + $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'overview'; // phpcs:ignore WordPress.Security.NonceVerification + $tabs = [ + 'overview' => __( 'Overview', 'aggregate-it' ), + 'activity' => __( 'Activity', 'aggregate-it' ), + ]; + if ( ! isset( $tabs[ $tab ] ) ) { + $tab = 'overview'; + } - $setup = [ + $s = $this->plugin->settings(); + $setup = [ 'provider' => $s->provider_key() !== 'mock' && $s->api_key() !== '', 'feeds' => (bool) $this->plugin->sources()->all(), 'types' => (bool) $this->plugin->rules()->post_types(), @@ -186,7 +185,41 @@ public function render_dashboard(): void { $show_setup = ! get_option( 'aggregate_it_setup_dismissed' ) && ( ! $setup['provider'] || ! $setup['feeds'] ); $can_seed = $this->plugin->seed_enabled(); - require AGGREGATE_IT_PATH . 'src/Admin/views/dashboard.php'; + if ( $tab === 'activity' ) { + // phpcs:disable WordPress.Security.NonceVerification + $per_page = 50; + $page = max( 1, (int) ( $_GET['paged'] ?? 1 ) ); + $filters = [ + 'level' => isset( $_GET['level'] ) ? sanitize_key( wp_unslash( $_GET['level'] ) ) : '', + 'type' => isset( $_GET['type'] ) ? sanitize_key( wp_unslash( $_GET['type'] ) ) : '', + 'item_id' => (int) ( $_GET['item'] ?? 0 ), + 'search' => isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : '', + ]; + // phpcs:enable WordPress.Security.NonceVerification + $total = ActivityLog::count( $filters ); + $rows = ActivityLog::query( $filters, $per_page, ( $page - 1 ) * $per_page ); + $pages = (int) max( 1, ceil( $total / $per_page ) ); + $levels = [ 'info', 'warning', 'error' ]; + $types = array_merge( Pipeline::default_order(), [ Schema::STATE_DEAD_LETTER ] ); + } + + echo '
'; + echo '

' . esc_html__( 'Aggregate It', 'aggregate-it' ) . '

'; + echo ''; + + $tab_embedded = true; + require AGGREGATE_IT_PATH . 'src/Admin/views/' . ( $tab === 'activity' ? 'activity.php' : 'dashboard.php' ); + + echo '
'; } public function handle_dismiss_setup(): void { @@ -904,27 +937,6 @@ public function handle_save_settings(): void { $this->redirect( self::SLUG . '-settings', 'saved' ); } - public function render_activity(): void { - // phpcs:disable WordPress.Security.NonceVerification - $per_page = 50; - $page = max( 1, (int) ( $_GET['paged'] ?? 1 ) ); - $filters = [ - 'level' => isset( $_GET['level'] ) ? sanitize_key( wp_unslash( $_GET['level'] ) ) : '', - 'type' => isset( $_GET['type'] ) ? sanitize_key( wp_unslash( $_GET['type'] ) ) : '', - 'item_id' => (int) ( $_GET['item'] ?? 0 ), - 'search' => isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : '', - ]; - // phpcs:enable WordPress.Security.NonceVerification - - $total = ActivityLog::count( $filters ); - $rows = ActivityLog::query( $filters, $per_page, ( $page - 1 ) * $per_page ); - $pages = (int) max( 1, ceil( $total / $per_page ) ); - $levels = [ 'info', 'warning', 'error' ]; - $types = array_merge( Pipeline::default_order(), [ Schema::STATE_DEAD_LETTER ] ); - - require AGGREGATE_IT_PATH . 'src/Admin/views/activity.php'; - } - public function handle_bulk_add_sources(): void { $this->guard( 'aggregate_it_bulk_add_sources' ); diff --git a/src/Admin/views/activity.php b/src/Admin/views/activity.php index af35a3b..20be5b2 100644 --- a/src/Admin/views/activity.php +++ b/src/Admin/views/activity.php @@ -11,19 +11,15 @@ defined( 'ABSPATH' ) || exit; -$base = admin_url( 'admin.php?page=aggregate-it-activity' ); +$base = admin_url( 'admin.php?page=aggregate-it&tab=activity' ); $label_for = static function ( string $state ): string { return $state === '' ? '' : ucwords( str_replace( '_', ' ', $state ) ); }; ?> -
-
-

-
-
- + + @@ -98,7 +94,8 @@ 'aggregate-it-activity', + 'page' => 'aggregate-it', + 'tab' => 'activity', 'level' => $filters['level'], 'type' => $filters['type'], 'item' => $filters['item_id'] ?: '', @@ -116,7 +113,6 @@

-