=== Profenv – Environment Profiles ===
Contributors: redwoodcity
Tags: environment, staging, gtm, ga4, settings
Requires at least: 5.5
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.7.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Store environment-specific values (GTM container ID, GA4 measurement ID, etc.) per environment and switch them automatically.

== Description ==

Profenv stores environment-specific values (such as a GTM container ID and a GA4 measurement ID) for each of your environments (production, staging, and any additional sets) and switches them automatically based on the environment the site is currently running in. It solves the common migration problem where production settings cannot be reused on staging, and vice versa.

* Four-step fallback environment detection: custom constant (wp-config.php), WP_ENVIRONMENT_TYPE (WP 5.5+), domain mapping, and undetermined as the last resort
* When the environment cannot be determined, output of environment-specific values is suspended and a warning is shown in the admin screen. This prevents staging tags from ever firing on production
* Field definitions (key and type, including code snippets) are shared across all environments, while each environment stores its own values
* Each environment can also define environment-specific fields (key, type, and value) that exist only in that environment
* When keys named gtm_id / ga4_id are defined and filled, the core plugin automatically outputs the GTM / GA4 tags with proper escaping; all other values are stored only and never output by the core plugin
* Public API for extensions and themes: profenv_current_env(), profenv_get(), and profenv_get_all(), each with a filter equivalent that returns a safe default when the plugin is inactive
* Shared field values are also readable through the standard option API — get_option( 'profenv_gtm_id' ) — and through ACF's get_field() with the same prefixed name, always returning the current environment's value
* Extensions can register their own fields via the profenv_register_fields filter and reuse the settings infrastructure

== External services ==

This plugin can connect to Google Tag Manager and Google Analytics 4, services provided by Google LLC. They are used to load the tag container / measurement snippet that the site administrator has configured. No connection is made at all unless you enter a GTM container ID and/or a GA4 measurement ID in the plugin settings.

When a GTM container ID is set, the standard Google Tag Manager snippet is output on every front-end page, and the visitor's browser loads https://www.googletagmanager.com/gtm.js (plus https://www.googletagmanager.com/ns.html inside a noscript iframe). When a GA4 measurement ID is set, the standard Google tag (gtag.js) snippet is output, and the visitor's browser loads https://www.googletagmanager.com/gtag/js. As a consequence of loading these scripts, the visitor's IP address, user agent, and the URL of the visited page are transmitted to Google on every front-end page view, and Google may collect additional analytics data according to how your Tag Manager container or Analytics property is configured.

The plugin itself sends no data to Google; requests are made by the visitor's browser only after you configure the IDs above. You are responsible for informing your visitors and obtaining any consent required in your jurisdiction (for example, via a consent management plugin).

* Google Tag Manager: [Use Policy](https://www.google.com/analytics/terms/tag-manager/), [Privacy Policy](https://policies.google.com/privacy)
* Google Analytics 4: [Terms of Service](https://marketingplatform.google.com/about/analytics/terms/us/), [Privacy Policy](https://policies.google.com/privacy)

== Changelog ==

= 0.7.1 =
* Renamed the admin menu entry from "Profenv" to "Environment Settings".
* When no environment sets have been saved yet, the staging set now defaults to the current domain, so a fresh install is never detected as production by domain mapping.
* Fixed the "Settings saved." notice being displayed twice after saving.

= 0.7.0 =
* Renamed the plugin to "Profenv – Environment Profiles" (slug: profenv) following plugin review feedback. All function, option, hook, and constant prefixes changed accordingly (the plugin has never been released, so no data migration is provided).
* The GTM / GA4 snippets are now registered via wp_enqueue_script() / wp_add_inline_script() instead of being printed directly into wp_head.
* Code-snippet field values are stored as-is only for users with the unfiltered_html capability; for other users they are filtered through wp_kses_post() on save.
* Added an "External services" section to the readme documenting the connection to googletagmanager.com.
* Uninstall now deletes only the plugin's known option names instead of a prefix-based bulk delete.

= 0.6.1 =
* Rewrote the plugin header Description in English; the Japanese description is now provided via the translation files. No functional changes.

= 0.6.0 =
* Added a read-only bridge for shared field values: get_option( 'profenv_{key}' ) and ACF's get_field( 'profenv_{key}' ) now return the current environment's value. Names that would collide with the plugin's own options are not bridged, and the bridge falls through to the normal resolution when the environment is undetermined or the value is empty.

= 0.5.1 =
* Updated the Help tab: added a Field definitions section and aligned the per-environment description with the current UI. No functional changes.

= 0.5.0 =
* Added environment-specific fields: in addition to the shared field definitions, each environment tab can now define its own fields (key, type, and value) that exist only in that environment. Legacy custom fields are migrated into environment-specific fields on read.

= 0.4.0 =
* Replaced the standard/custom two-tier fields with field definitions (key and type) shared across all environments; each environment now stores only its values.
* GTM / GA4 tags are auto-output when keys named gtm_id / ga4_id are defined and filled (they are provided as the default field definitions).
* Values stored in the previous structure are migrated on read.

= 0.3.0 =
* Added a Help tab covering the plugin overview, how environment detection works, environment sets, per-environment settings, and the developer API (constant, functions, filters, field registration).

= 0.2.5 =
* Removed the descriptive notes from the standard fields and custom fields sections. No functional changes.

= 0.2.4 =
* Removed the note about administrator capability and nonce verification from the save rows. No functional changes.

= 0.2.3 =
* Rewrote readme.txt in English and marked the plugin as tested up to WordPress 7.0 (plugin review requirements).
* Removed the load_plugin_textdomain() call; WordPress loads translations automatically. No functional changes.

= 0.2.2 =
* Refreshed the admin UI with the Mail Guardpost design tokens (info bar, card-style tab panel, sections, environment set table, diagnostics box). Saved environment set keys are no longer editable because they are data identifiers. No functional changes.

= 0.2.1 =
* Added Japanese translation (languages/profenv-ja.po / .mo). No functional changes.

= 0.2.0 =
* Implemented the admin settings UI (Environments & Detection tab, per-environment tabs, custom field repeater, extension field groups).
* Implemented saving of per-environment settings with type-aware sanitization (code snippets are stored as-is, relying on administrator capability).
* Added environment set management (up to 10 sets; production and staging cannot be removed) and detection method selection (custom constant / WP_ENVIRONMENT_TYPE / domain mapping only).
* Implemented automatic front-end output of the standard fields (GTM container ID / GA4 measurement ID). Output is suspended while the environment is undetermined.

= 0.1.0 =
* Initial project scaffold.
