WordPress plugin intelligence profile

PHP Constants Manager

Safely manage PHP constants (defines) through the WordPress admin or WP-CLI with full CRUD functionality and comprehensive viewing capabilities.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 7.1
Current version1.2.2
WordPress coverageTested up to WordPress 7.1
Minimum stackWP 5.0 · PHP 7.4
Directory statusactive
Last directory update25 Aug 20262mo ago
Active installations10Adoption metric — not a quality score
WordPress.org rating5.0 / 5 from 1 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records PHP Constants Manager version 1.2.2 as active, updated 2mo ago and tested up to WordPress 7.1.

Overview

About this plugin

PHP Constants Manager provides a secure and user-friendly interface for managing PHP constants in WordPress. php or theme files to add or modify constants!

Key Features

  • Complete Constant Management: Create, read, update, and delete PHP constants from the WordPress admin
  • Dual View System: “My Constants” for your custom constants and “All Constants” to view every constant in your WordPress installation
  • Native WordPress UI: Built using WP_List_Table with sorting, searching, and bulk actions
  • Multiple Data Types: Support for String, Integer, Float, Boolean, and NULL constant types with strict validation
  • Real-time Validation: Form fields validate values against selected type with immediate feedback
  • Active/Inactive States: Toggle constants on/off without deleting them
  • Conflict Detection: Visual indicators show when constants are already defined elsewhere (predefined)
  • Screen Options: Customize table views with adjustable items per page and column visibility controls
  • Early Loading Option: Optional must-use plugin creation for loading constants before other plugins
  • Load Order Awareness: Constants loaded during plugins_loaded action (priority 1) for broad compatibility
  • Comprehensive Help: Built-in help system with detailed documentation and best practices
  • Administrator Only: Secure access restricted to users with manage_options capability
  • Database Storage: Constants stored safely in a custom database table with full audit trail
  • Import/Export: Backup and migrate constants using CSV files with detailed error reporting
  • WP-CLI Integration: Manage constants, import/export CSV, and toggle early loading from the terminal via wp phpcm... — ideal for automation, CI/CD, and multi-site provisioning

Understanding Predefined Constants

The plugin intelligently detects when constants are already defined by WordPress core, other plugins, or your theme:

* Not Predefined: Your constant is unique and will work normally

* Predefined: The constant exists elsewhere – your definition is saved but won’t override the existing value due to PHP’s constant rules

Use Cases

  • Manage environment-specific configuration
  • Toggle debug constants without file editing
  • Store API keys and configuration values securely
  • Create fallback constants for different environments
  • Document constant purposes with built-in descriptions
  • Audit all constants in your WordPress installation
  • Backup constants to CSV files for migration between sites
  • Import constants in bulk from properly formatted CSV files
  • Automate site setup and deployment pipelines with WP-CLI ( wp phpcm add MY_KEY... )

WP-CLI Commands

When WP-CLI is available, the plugin registers a phpcm command suite that mirrors the admin UI:

  • wp phpcm list [--active] [--inactive] [--type=<type>] [--search=<term>] [--format=<format>] — list managed constants
  • wp phpcm get <name> — show a single constant (supports --field=<field> )
  • wp phpcm add <name> [<value>] [--type=<type>] [--description=<text>] [--inactive] [--porcelain] — create a constant (value can be - to read from stdin)
  • wp phpcm update <name> [--value=<value>] [--type=<type>] [--description=<text>] [--active|--inactive] — update fields
  • wp phpcm delete <name>... [--yes] — delete one or more by name
  • wp phpcm activate|deactivate|toggle <name>... — flip active state
  • wp phpcm defined <name> — report whether the constant is currently defined and by whom (this plugin, early-load, or elsewhere like wp-config.php)
  • wp phpcm all-defines [--user-defined] [--search=<term>] — inspect every PHP constant present in the process
  • wp phpcm status — plugin health summary (table, row counts, early-loading state)
  • wp phpcm import <file|-> [--overwrite] — import CSV (file path or stdin)
  • wp phpcm export [<file>] [--active] [--inactive] [--type=<type>] — write CSV to a file or stdout
  • wp phpcm early-loading enable|disable|status — manage the must-use plugin that loads constants before all other plugins

Run wp help phpcm <subcommand> for detailed usage, flags, and examples.

Developer Information

Database Schema

The plugin creates a custom table {prefix}phpcm_constants with the following structure:

* id – Primary key (auto-increment)

* name – Constant name (unique, varchar 191)

* value – Constant value (longtext)

* type – Data type (enum: string, integer, float, boolean, null)

* is_active – Whether the constant is loaded (tinyint)

* description – Optional description (text)

* created_at – Creation timestamp (datetime)

* updated_at – Last update timestamp (datetime)

WordPress Hooks Used

  • plugins_loaded (priority 1) – Early constant loading for maximum compatibility
  • admin_menu – Menu registration
  • admin_post_* – Form submission handling
  • wp_ajax_* – AJAX operations
  • WP_CLI::add_command('phpcm',...) – Registers the CLI command when WP-CLI is available

Load Order & Compatibility

Constants are defined during plugins_loaded with priority 1, ensuring they are available to:

* All theme functions and templates

* Other plugins (unless using higher priority)

* WordPress core hooks like init, wp_loaded, etc.

Security Implementation

  • Capability requirement: manage_options (administrators only)
  • Nonce verification on all form submissions and AJAX requests
  • SQL injection prevention with prepared statements
  • Input sanitization using WordPress core functions
  • Output escaping for all displayed data

Code Standards

This plugin follows WordPress coding standards and best practices:

* PSR-4 autoloading structure

* WordPress database abstraction layer

* Internationalization ready

* WP_List_Table implementation

* Standard WordPress admin UI patterns

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • admin
  • configuration
  • constants
  • defines
  • php
Compatibility & maintenance

Compatibility & maintenance

Tested with WP 7.1

Marked as tested with the current WordPress 7.1 release.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to7.1
Minimum requirementsWordPress 5.0 · PHP 7.4
Update activity25 Aug 20262mo ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.