Documentation

Developer information for using Profenv from your theme or an extension plugin.

Public API

  • profenv_current_env() — returns the current environment key (e.g. 'production' / 'staging' / 'unknown').
  • profenv_get( $key, $default, $env ) — returns the value for a key. Passing $env retrieves another environment’s value regardless of the current one.
  • profenv_get_all( $env ) — returns all values for an environment as an array.

Each has a filter equivalent under the same name, so a safe default is returned through the filter even when the plugin is inactive.

// Function form
$ga4 = profenv_get( 'ga4_id', '', 'staging' );

// Filter form (degrades safely when the core is inactive)
$env = apply_filters( 'profenv_current_env', 'production' );

get_option / ACF bridge

Shared field values are also readable through get_option( 'profenv_<key>' ) and ACF’s get_field( 'profenv_<key>' ). This read-only bridge always returns the current environment’s value; keys that would collide with the plugin’s own options are excluded, and it falls through to the normal resolution when the environment is undetermined or the value is empty.

Registering custom fields

Extensions can register their own fields (key, label, type, sanitization method, and extension identifier) via the profenv_register_fields filter and reuse the core settings infrastructure. The core and extensions are loosely coupled; an extension degrades safely with function_exists() when the core is inactive.

External services (GTM / GA4)

The plugin outputs Google Tag Manager / Google Analytics 4 snippets only when an administrator configures them. No external connection is made at all unless you enter an ID. Once an ID is set, the visitor’s browser loads scripts from googletagmanager.com. The plugin itself never sends any data to Google.

← Back to home

Copied title and URL