diff --git a/CHANGELOG.md b/CHANGELOG.md index adc7bd9..868fa1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,18 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.4.2] - 2026-02-02 +## [0.4.3] - 2026-02-02 ### Added -- Option to disable early mode in admin settings (Metrics tab) +- Sub-tabs navigation within Metrics tab (Endpoint, Selection, Runtime, Advanced) +- Option to disable early mode in admin settings (Metrics → Advanced) - Support for `WP_PROMETHEUS_DISABLE_EARLY_MODE` environment variable - Early mode status display in settings +### Fixed + +- Early mode setting now saves correctly (moved into form with proper settings group) + ### Changed -- Early mode can now be disabled for users who need the `wp_prometheus_collect_metrics` hook for custom metrics -- Updated translations with new early mode strings (English and German) +- Reorganized Metrics tab into logical sub-sections for better usability +- Early mode can now be disabled for users who need the `wp_prometheus_collect_metrics` hook +- Updated translations with sub-tab and early mode strings (English and German) ## [0.4.1] - 2026-02-02 diff --git a/CLAUDE.md b/CLAUDE.md index 8fadf55..eb24c7f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -291,6 +291,20 @@ add_action( 'wp_prometheus_collect_metrics', function( $collector ) { ## Session History +### 2026-02-02 - Sub-tabs & Early Mode Fix (v0.4.3) + +- Split Metrics tab into sub-tabs for better organization: + - **Endpoint**: Authentication token configuration + - **Selection**: Enable/disable individual metrics + - **Runtime**: Reset runtime metrics data + - **Advanced**: Early mode toggle and status +- Fixed early mode setting not being saved (was outside form element) +- Added CSS styling for horizontal sub-tab navigation +- **Key Learning**: WordPress Settings API form structure + - Settings must be inside `
` with `settings_fields()` call + - Each sub-tab needs its own form wrapper for proper saving + - Sub-tabs use URL query parameter (`subtab`) within the main tab + ### 2026-02-02 - Early Mode Toggle (v0.4.2) - Added option to disable early mode for users who need extensibility diff --git a/assets/css/admin.css b/assets/css/admin.css index 785bc62..54b908e 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -9,6 +9,61 @@ margin-top: 20px; } +/* Sub-tabs navigation */ +.wp-prometheus-subtabs { + margin-top: 15px; +} + +.wp-prometheus-subtab-nav { + display: flex; + margin: 0 0 20px 0; + padding: 0; + list-style: none; + border-bottom: 1px solid #c3c4c7; +} + +.wp-prometheus-subtab-item { + margin: 0; + padding: 0; +} + +.wp-prometheus-subtab-item a { + display: block; + padding: 8px 16px; + text-decoration: none; + color: #50575e; + border: 1px solid transparent; + border-bottom: none; + margin-bottom: -1px; + background: transparent; + font-size: 13px; + font-weight: 400; +} + +.wp-prometheus-subtab-item a:hover { + color: #2271b1; + background: #f6f7f7; +} + +.wp-prometheus-subtab-item.active a { + color: #1d2327; + background: #fff; + border-color: #c3c4c7; + border-bottom-color: #fff; + font-weight: 600; +} + +.wp-prometheus-subtab-content { + background: #fff; + border: 1px solid #c3c4c7; + border-top: none; + padding: 20px; +} + +.wp-prometheus-subtab-content h3:first-child { + margin-top: 0; +} + /* License status box */ .wp-prometheus-license-status { margin: 15px 0; diff --git a/languages/wp-prometheus-de_CH.mo b/languages/wp-prometheus-de_CH.mo index 0ec05dd..415103a 100644 Binary files a/languages/wp-prometheus-de_CH.mo and b/languages/wp-prometheus-de_CH.mo differ diff --git a/languages/wp-prometheus-de_CH.po b/languages/wp-prometheus-de_CH.po index 4dd24e4..c6cc7de 100644 --- a/languages/wp-prometheus-de_CH.po +++ b/languages/wp-prometheus-de_CH.po @@ -919,3 +919,31 @@ msgstr "Fruehzeitiger Modus ist aktiviert (aktiv fuer /metrics-Anfragen)" #: src/Admin/Settings.php msgid "Clear all accumulated runtime metric data (HTTP requests, database queries). This is useful for testing or starting fresh." msgstr "Alle gesammelten Laufzeit-Metrikdaten loeschen (HTTP-Anfragen, Datenbank-Abfragen). Dies ist nuetzlich zum Testen oder fuer einen Neuanfang." + +#: src/Admin/Settings.php +msgid "Endpoint" +msgstr "Endpunkt" + +#: src/Admin/Settings.php +msgid "Selection" +msgstr "Auswahl" + +#: src/Admin/Settings.php +msgid "Runtime" +msgstr "Laufzeit" + +#: src/Admin/Settings.php +msgid "Advanced" +msgstr "Erweitert" + +#: src/Admin/Settings.php +msgid "Runtime Metrics Management" +msgstr "Laufzeit-Metriken Verwaltung" + +#: src/Admin/Settings.php +msgid "Runtime metrics track HTTP requests and database queries across requests. Use this section to manage accumulated data." +msgstr "Laufzeit-Metriken erfassen HTTP-Anfragen und Datenbank-Abfragen ueber mehrere Anfragen hinweg. Verwenden Sie diesen Bereich zur Verwaltung der gesammelten Daten." + +#: src/Admin/Settings.php +msgid "Reset Data" +msgstr "Daten zuruecksetzen" diff --git a/languages/wp-prometheus.pot b/languages/wp-prometheus.pot index 2e86aa8..fd5b117 100644 --- a/languages/wp-prometheus.pot +++ b/languages/wp-prometheus.pot @@ -916,3 +916,31 @@ msgstr "" #: src/Admin/Settings.php msgid "Clear all accumulated runtime metric data (HTTP requests, database queries). This is useful for testing or starting fresh." msgstr "" + +#: src/Admin/Settings.php +msgid "Endpoint" +msgstr "" + +#: src/Admin/Settings.php +msgid "Selection" +msgstr "" + +#: src/Admin/Settings.php +msgid "Runtime" +msgstr "" + +#: src/Admin/Settings.php +msgid "Advanced" +msgstr "" + +#: src/Admin/Settings.php +msgid "Runtime Metrics Management" +msgstr "" + +#: src/Admin/Settings.php +msgid "Runtime metrics track HTTP requests and database queries across requests. Use this section to manage accumulated data." +msgstr "" + +#: src/Admin/Settings.php +msgid "Reset Data" +msgstr "" diff --git a/src/Admin/Settings.php b/src/Admin/Settings.php index 0761488..9b37afb 100644 --- a/src/Admin/Settings.php +++ b/src/Admin/Settings.php @@ -400,95 +400,228 @@ class Settings { __( 'Endpoint', 'wp-prometheus' ), + 'selection' => __( 'Selection', 'wp-prometheus' ), + 'runtime' => __( 'Runtime', 'wp-prometheus' ), + 'advanced' => __( 'Advanced', 'wp-prometheus' ), + ); + } + + /** + * Get current metrics sub-tab. + * + * @return string + */ + private function get_current_metrics_subtab(): string { + $subtab = isset( $_GET['subtab'] ) ? sanitize_key( $_GET['subtab'] ) : 'endpoint'; + $subtabs = $this->get_metrics_subtabs(); + return array_key_exists( $subtab, $subtabs ) ? $subtab : 'endpoint'; + } + /** * Render metrics tab content. * * @return void */ private function render_metrics_tab(): void { + $subtabs = $this->get_metrics_subtabs(); + $current_subtab = $this->get_current_metrics_subtab(); ?> - - -
+
+ -
- -

-

-

- - -

- - -
- - render_early_mode_section(); ?> +
+ render_metrics_endpoint_subtab(); + break; + case 'selection': + $this->render_metrics_selection_subtab(); + break; + case 'runtime': + $this->render_metrics_runtime_subtab(); + break; + case 'advanced': + $this->render_metrics_advanced_subtab(); + break; + } + ?> +
+
-

-

- -

+
+ - -
- -

-
- +

+

+ + + + + + + + + +
+ +
+ + +

+

+ + + + + + + + + +
+ +

+

- + - - - - +
+ + +

+

+ +

+ + +
+ +

+
+ + + + + + + + + + + + + + +
+