feat: Add option to disable early mode (v0.4.2)
All checks were successful
Create Release Package / build-release (push) Successful in 56s

- Add wp_prometheus_disable_early_mode option in admin settings
- Support WP_PROMETHEUS_DISABLE_EARLY_MODE environment variable
- Add Early Mode section in Metrics tab with status indicator
- Allow users to enable wp_prometheus_collect_metrics hook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 21:09:14 +01:00
parent fa63857f5f
commit 19d75ab7b2
7 changed files with 193 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
* Plugin Name: WP Prometheus
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-prometheus
* Description: Prometheus metrics endpoint for WordPress with extensible hooks for custom metrics.
* Version: 0.4.1
* Version: 0.4.2
* Requires at least: 6.4
* Requires PHP: 8.3
* Author: Marco Graetsch
@@ -37,6 +37,18 @@ function wp_prometheus_early_metrics_check(): void {
return;
}
// Check if early mode is disabled via environment variable.
$env_disable = getenv( 'WP_PROMETHEUS_DISABLE_EARLY_MODE' );
if ( false !== $env_disable && in_array( strtolower( $env_disable ), array( '1', 'true', 'yes', 'on' ), true ) ) {
return;
}
// Check if early mode is disabled via option.
// We can use get_option() here because WordPress core is already loaded.
if ( get_option( 'wp_prometheus_disable_early_mode', false ) ) {
return;
}
// Check if autoloader exists.
$autoloader = __DIR__ . '/vendor/autoload.php';
if ( ! file_exists( $autoloader ) ) {
@@ -118,7 +130,7 @@ wp_prometheus_early_metrics_check();
*
* @var string
*/
define( 'WP_PROMETHEUS_VERSION', '0.4.1' );
define( 'WP_PROMETHEUS_VERSION', '0.4.2' );
/**
* Plugin file path.