From cf1797d4bf56dcd199de6762ebc7ecf3e8197736 Mon Sep 17 00:00:00 2001 From: magdev Date: Mon, 2 Feb 2026 21:45:36 +0100 Subject: [PATCH] feat: Split Metrics tab into sub-tabs and fix early mode storage (v0.4.3) - Add sub-tabs: Endpoint, Selection, Runtime, Advanced - Fix early mode checkbox not saving (was outside form element) - Add CSS styling for horizontal sub-tab navigation - Update translations with new sub-tab strings Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 14 +- CLAUDE.md | 14 ++ assets/css/admin.css | 55 +++++++ languages/wp-prometheus-de_CH.mo | Bin 20435 -> 20987 bytes languages/wp-prometheus-de_CH.po | 28 ++++ languages/wp-prometheus.pot | 28 ++++ src/Admin/Settings.php | 255 +++++++++++++++++++++++-------- wp-prometheus.php | 2 +- 8 files changed, 330 insertions(+), 66 deletions(-) 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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UQopGnzs^Heee1PT^lcI0i4`7L3OgT%@($jjA8S zL~O$Z^quMqAQ?5FJRFKk(1qJ^I37kV!QauX3vW=EgRW`Ljn<$>Z~%4Tar8kCd5Dyg zwM54lQb#g~j=7|OWD*zA(M$#t&0-B%NOlnpjo-c;@Ch=Hs8ecK2R~fiU$Eoen)7D} zJWpOCzavXY68SATNpyTo9w04bJLx?BXbX?v`)Yp;g(iFQR(yr@CAp-S=y;TTPBbea zWESDUFh_}worEXZyKL+`v!3iBoyQ3Z6UpQD#52gMnQa<>GKnE^L{Ea&Ovio)@8()g zc?nrz&uzje5@_omTVKZ%@+a~zd5-*^=wKDS`)fLO*9i{ypZRl+Xd}HybUf`~#^WjC zN8Tm%n3X6z8(MyfP?fs!Cp>%*O&?$~P zNVT`bZnak7DqEgl6%UeHTh|L~C3%yur@fEoG2{Uw)}?m9jiD^%E-&A{NjkT}{lRR=C z*-aLc&VlTs98Nlq`4pZaGstH074ao+5f0~TK~BZ{ixy2e-q!zseMk{mMs%EUFkj$j zq>HV8U=7CmNj3>1uaPgwI __( '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(); ?> - - - +
+
    + $subtab_name ) : ?> + 'wp-prometheus', + 'tab' => 'metrics', + 'subtab' => $subtab_id, + ), + admin_url( 'options-general.php' ) + ); + $active_class = ( $current_subtab === $subtab_id ) ? ' active' : ''; + ?> +
  • + +
  • + +
-
- -

-

-

- - -

- - -
- - 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; + } + ?> +
+
-

-

- -

+
+ - -
- -

-
- +

+

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

+

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

+

- + - - - - +
+ + +

+

+ +

+ + +
+ +

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