WP Manifestindependent plugin directory
manifest / developer / env-configuration-manager

Env Manager

A WordPress plugin for managing environment-specific configuration and integrations across Production, Stage, QA, and Pre-Production environments.

by Shahid Ajmeri · github.com/shahidajmeri2214/env-configuration-manager · website

1stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/shahidajmeri2214/env-configuration-manager/archive/refs/heads/main.zip

Readme

Env Manager

A WordPress plugin for managing environment-specific configuration and integrations across Production, Stage, QA, and Pre-Production environments.

Env Manager automatically identifies the current WordPress environment based on the configured site URL and loads the appropriate configuration for analytics, Google Tag Manager, reCAPTCHA, and Contact Form 7 CRM integrations.

Features

  • 🌍 Environment detection based on WordPress site URL
  • 🏭 Production environment configuration
  • 🧪 Stage environment configuration
  • 🔍 QA environment configuration
  • 🚀 Pre-Production environment configuration
  • 📊 Environment-specific Google Analytics configuration
  • 📈 Support for a secondary Google Analytics / Google Ads tracking ID
  • 🏷️ Environment-specific Google Tag Manager configuration
  • 🛡️ Environment-specific Google reCAPTCHA site and secret keys
  • 🔗 Contact Form 7 CRM API integration
  • 🔀 Automatic Production vs. Staging CRM API selection
  • 🎯 Optional selective Contact Form 7 field submission
  • 🔢 Integer field support for CRM payloads
  • 🔌 Filter support for extending CRM API payloads
  • ⚙️ Centralized WordPress Admin settings
  • 🧩 Built using the WordPress Plugin Boilerplate architecture

Supported Environments

Env Manager currently supports four environments:

Environment Purpose
Production Live production website
Stage Staging/development environment
QA Quality assurance environment
Pre-Prod Pre-production validation environment

The environment is determined by comparing the current WordPress site URL returned by:

get_site_url()

against the configured environment URLs.

Environment Detection

Each environment has its own URL configuration.

For example:

Production → https://www.example.com
Stage      → https://stage.example.com
QA         → https://qa.example.com
Pre-Prod   → https://preprod.example.com

When WordPress initializes, the plugin compares the current site URL with these configured values and defines the environment.

Example:

ENV_TYPE

Possible values are:

production
stage
qa
pre-prod

The detected environment is also stored in the WordPress option:

env_type

If no configured URL matches the current site URL, the plugin falls back to Stage.

Admin Settings

After activation, the plugin adds an Env Manager menu to the WordPress administration area.

The settings screen provides separate tabs for:

  • Production
  • Stage
  • QA
  • Pre-Prod

Each environment can be configured independently.

Configuration Fields

Each environment supports:

Configuration Supported
Environment URL
Google Analytics ID
Secondary Analytics / Ads ID
Google Tag Manager ID
reCAPTCHA Site Key
reCAPTCHA Secret Key
CRM API URL Contact Form 7
Staging CRM API URL Contact Form 7

Google Analytics

The plugin supports environment-specific Google Analytics configuration.

For example:

Production → production_ga_code
Stage      → stage_ga_code
QA         → qa_ga_code
Pre-Prod   → pre_prod_ga_code

The appropriate tracking ID is automatically selected based on the detected environment.

The plugin outputs the Google Analytics gtag.js implementation into the site's <head>.

Secondary Tracking ID

A second tracking identifier can also be configured for each environment.

Configuration keys:

production_ga_code_2
stage_ga_code_2
qa_ga_code_2
pre_prod_ga_code_2

This can be used for an additional Google Analytics or Google Ads tracking configuration.

Google Tag Manager

Google Tag Manager can also be configured independently for every environment.

Example:

production_gtm_code
stage_gtm_code
qa_gtm_code
pre_prod_gtm_code

The plugin automatically loads the GTM container associated with the detected environment.

The standard GTM implementation is added in two locations:

<head>

The asynchronous Google Tag Manager script is loaded through the wp_head hook.

<body>

The GTM noscript iframe is added through:

wp_body_open

This allows each environment to use a different GTM container without requiring theme-level code changes.

Google reCAPTCHA

Env Manager supports environment-specific Contact Form 7 reCAPTCHA credentials.

Each environment can have its own:

Site Key
Secret Key

Configuration examples:

production_r_site_key
production_r_seceret_key

stage_r_site_key
stage_r_seceret_key

qa_r_site_key
qa_r_seceret_key

pre_prod_r_site_key
pre_prod_r_seceret_key

When the site loads, the plugin detects the current environment and exposes the corresponding keys to Contact Form 7.

This allows Production and non-Production environments to use separate reCAPTCHA credentials.

Contact Form 7 CRM Integration

Env Manager extends Contact Form 7 with a custom CRM configuration panel.

A new panel called:

CRM Details

is added to the Contact Form 7 form editor.

The CRM configuration supports:

  • Enable/disable CRM submission
  • Production CRM API URL
  • Staging CRM API URL
  • Selective field submission
  • Integer field conversion
  • Custom payload filtering

CRM Configuration

Each Contact Form 7 form can have its own CRM configuration.

The following values are stored as post metadata:

_wpcf7_crm_form_status
_wpcf7_crm_form_fields
_wpcf7_crm_api_url
_wpcf7_crm_stage_api_url

CRM Form Status

The CRM integration can be enabled or disabled for an individual Contact Form 7 form.

When disabled, no CRM API request is sent.

Production vs. Non-Production API

The plugin automatically selects the CRM API based on the detected environment.

Production:

Production CRM API URL

Non-production:

Staging CRM API URL

This prevents Stage, QA, and Pre-Prod forms from accidentally submitting data to the Production CRM endpoint.

Selective Field Submission

The plugin supports sending only specific Contact Form 7 fields to the CRM API.

When Specific Fields is enabled, fields must include:

class:cf7crmsave

Example:

[text first-name class:cf7crmsave]

Only fields marked with the cf7crmsave class are included in the CRM payload.

When selective field mode is disabled, the plugin processes the available Contact Form 7 submission fields.

Integer Field Support

Fields can be marked with:

class:integer

to force their value to be converted to an integer before being sent to the CRM API.

Example:

[text age class:cf7crmsave class:integer]

This allows CRM integrations to receive numeric values instead of strings.

CRM API Request

The plugin sends the CRM payload using WordPress's:

wp_safe_remote_post()

The request uses:

POST
Content-Type: application/json

Example payload:

{
  "first_name": "John",
  "last_name": "Doe",
  "email": "john@example.com"
}

The response status code and response message are passed back to Contact Form 7.

Extending CRM Payloads

The plugin provides a dynamic WordPress filter for extending the CRM payload:

cf7_crm_api_extra_{POST_ID}

Example:

add_filter(
    'cf7_crm_api_extra_123',
    function ($data, $post_id, $form_array) {

        $form_array['source'] = 'website';

        return $form_array;
    },
    10,
    3
);

This allows individual Contact Form 7 forms to add or modify CRM payload fields without modifying the plugin itself.

WordPress Hooks Used

The plugin integrates with WordPress using standard actions and filters.

Admin

admin_menu
admin_init
admin_enqueue_scripts

Environment Detection

init

Analytics / Tracking

wp_head
wp_body_open

Contact Form 7

wpcf7_editor_panels
wpcf7_after_save
wpcf7_before_send_mail

Frontend Assets

wp_enqueue_scripts

Installation

Method 1 — Upload ZIP

  1. Download the plugin ZIP.
  2. Log in to WordPress Admin.
  3. Navigate to:
Plugins → Add New → Upload Plugin
  1. Upload the env-manager.zip file.
  2. Install the plugin.
  3. Activate Env Manager.

Method 2 — Manual Installation

Copy the plugin directory into:

wp-content/plugins/

The structure should look like:

wp-content/
└── plugins/
    └── env-manager/
        ├── env-manager.php
        ├── admin/
        ├── includes/
        ├── public/
        ├── languages/
        ├── README.txt
        └── uninstall.php

Activate the plugin from:

WordPress Admin → Plugins

Configuration

After activation:

  1. Open Env Manager from the WordPress Admin menu.
  2. Open the Production tab.
  3. Enter the Production site URL.
  4. Configure the Production Analytics ID.
  5. Configure the Production GTM container ID.
  6. Configure Production reCAPTCHA credentials.
  7. Configure the Stage, QA, and Pre-Prod environments in the same way.
  8. Save each environment's configuration.

Example Configuration

Production
──────────────────────────────
URL: https://www.example.com
GA Code: G-XXXXXXXXXX
Secondary GA/Ads Code: AW-XXXXXXXXXX
GTM Code: GTM-XXXXXXX
reCAPTCHA Site Key: ********
reCAPTCHA Secret Key: ********


Stage
──────────────────────────────
URL: https://stage.example.com
GA Code: G-YYYYYYYYYY
Secondary GA/Ads Code: AW-YYYYYYYYYY
GTM Code: GTM-YYYYYYY
reCAPTCHA Site Key: ********
reCAPTCHA Secret Key: ********


QA
──────────────────────────────
URL: https://qa.example.com
GA Code: G-ZZZZZZZZZZ
Secondary GA/Ads Code: AW-ZZZZZZZZZZ
GTM Code: GTM-ZZZZZZZ
reCAPTCHA Site Key: ********
reCAPTCHA Secret Key: ********


Pre-Prod
──────────────────────────────
URL: https://preprod.example.com
GA Code: G-AAAAAAAAAA
Secondary GA/Ads Code: AW-AAAAAAAAAA
GTM Code: GTM-AAAAAAA
reCAPTCHA Site Key: ********
reCAPTCHA Secret Key: ********

Requirements

  • WordPress
  • PHP 7.4+
  • Administrator access for configuration
  • Contact Form 7 for CRM functionality
  • Valid Google Analytics IDs if analytics tracking is required
  • Valid Google Tag Manager container IDs if GTM is required
  • Valid reCAPTCHA credentials if Contact Form 7 reCAPTCHA is required

Plugin Architecture

The plugin follows the WordPress Plugin Boilerplate structure.

env-manager/
│
├── env-manager.php
│
├── admin/
│   ├── class-env-manager-admin.php
│   ├── css/
│   ├── js/
│   ├── partials/
│   └── index.php
│
├── includes/
│   ├── class-env-manager.php
│   ├── class-env-manager-loader.php
│   ├── class-env-manager-i18n.php
│   ├── class-env-manager-activator.php
│   ├── class-env-manager-deactivator.php
│   └── index.php
│
├── public/
│   ├── class-env-manager-public.php
│   ├── css/
│   ├── js/
│   ├── partials/
│   └── index.php
│
├── languages/
│
├── uninstall.php
└── README.txt

Main Components

env-manager.php

Plugin bootstrap file responsible for:

  • Plugin metadata
  • Version definition
  • Activation hooks
  • Deactivation hooks
  • Loading the core plugin class
  • Starting plugin execution

includes/class-env-manager.php

Core plugin class responsible for:

  • Loading dependencies
  • Initializing localization
  • Registering admin hooks
  • Registering public hooks
  • Starting the plugin loader

admin/class-env-manager-admin.php

Contains the main functionality, including:

  • Environment settings UI
  • Environment detection
  • Settings registration
  • Google Analytics integration
  • Google Tag Manager integration
  • reCAPTCHA configuration
  • Contact Form 7 CRM integration
  • CRM API submission
  • CRM field processing

public/class-env-manager-public.php

Handles public-facing plugin assets.

uninstall.php

Provides the WordPress uninstall entry point.

Security Considerations

The plugin uses WordPress's Settings API for environment configuration.

When deploying this plugin:

  • Restrict WordPress administrator access.
  • Do not commit real API URLs containing sensitive credentials.
  • Do not commit reCAPTCHA secret keys to Git.
  • Use environment-specific secrets where possible.
  • Review access to the Env Manager settings page.
  • Use HTTPS for CRM API endpoints.
  • Ensure production and non-production API endpoints are correctly configured.

Important: reCAPTCHA secret keys and other sensitive values should never be committed to a public Git repository.

Important Production Considerations

Before deploying the plugin to production, verify:

  • Production URL is configured correctly.
  • Stage URL is configured correctly.
  • QA URL is configured correctly.
  • Pre-Prod URL is configured correctly.
  • Correct GTM container is assigned to each environment.
  • Correct Analytics IDs are assigned to each environment.
  • Correct reCAPTCHA credentials are assigned to each environment.
  • Production forms point to the Production CRM API.
  • Stage/QA/Pre-Prod forms point to the non-production CRM API.
  • No production credentials are stored in source control.

Known Behavior

If the current WordPress site URL does not match any configured environment URL, Env Manager defaults the environment to:

Stage

This behavior should be reviewed when deploying the plugin to a new environment.

Read the full README on GitHub →