JPKCom Harden & Trim

status.php

Effective status of every setting

One answer to "what does this plugin do on this site right now, and why", shared by the WP-CLI command and the Abilities API, so the two cannot drift apart. It reports what the settings page cannot show at a glance: a switch can be on and still do nothing (kill switch, a core constant that wins, a block theme), and a value can come from somewhere other than the form (a plugin constant, the jpkcom_harden_trim_settings filter).

Everything here is read through the store's own functions; nothing is re-derived from the option.

Tags
since
1.2.0

Table of Contents

Functions

jpkcom_harden_trim_unfiltered_settings()  : array<string, mixed>
Stored values with the valid plugin constants applied, before the filter.
jpkcom_harden_trim_is_block_theme()  : bool
Whether the active theme is a block theme, when that can be known.
jpkcom_harden_trim_status()  : array{kill_switch: array{defined: bool, valid: bool, active: bool}, invalid_constants: list, block_theme: bool, exempt_roles: list, settings: list>}
The effective status of every setting.
jpkcom_harden_trim_status_late_constant()  : array{name: string, value: mixed}|null
A core constant defined after the plugin's load-time snapshot that keeps an active setting from acting.
jpkcom_harden_trim_status_scalar()  : bool|int|float|string|null
A core constant's value as a JSON scalar.

Functions

jpkcom_harden_trim_unfiltered_settings()

Stored values with the valid plugin constants applied, before the filter.

jpkcom_harden_trim_unfiltered_settings() : array<string, mixed>

The same two steps jpkcom_harden_trim_settings() takes before it applies jpkcom_harden_trim_settings, so a difference to the effective settings is exactly what the filter changed.

Tags
since
1.2.0
Return values
array<string, mixed> —

Key => value.

jpkcom_harden_trim_is_block_theme()

Whether the active theme is a block theme, when that can be known.

jpkcom_harden_trim_is_block_theme() : bool

wp_is_block_theme() is only reliable from after_setup_theme on; before that the answer is false, as it is for the feature code.

Tags
since
1.2.0
Return values
bool

jpkcom_harden_trim_status()

The effective status of every setting.

jpkcom_harden_trim_status() : array{kill_switch: array{defined: bool, valid: bool, active: bool}, invalid_constants: list, block_theme: bool, exempt_roles: list, settings: list>}

Per key:

  • value: the plugin's effective value (constant, else stored, else default, then the filter). A core constant does not change it, because core does not change it either; see core_value.
  • source: where value comes from: core_constant (a core constant defined before the plugin loaded decides instead of the plugin), constant, filter, stored or default.
  • locked_by: the constant the settings page names as the lock, or null.
  • acts / reason: whether the plugin's feature does something on this request, and if not, why: kill_switch, core_constant (also a core constant another plugin defined before this one could), block_theme (not available with a block theme), plain_permalinks (the author-enumeration block needs pretty permalinks), unused (a role list nothing reads right now) or off. Role-scoped features (role_scoped) still skip users holding an exempt role; that is decided per user and is not reflected in acts.
Tags
since
1.2.0
Return values
array{kill_switch: array{defined: bool, valid: bool, active: bool}, invalid_constants: list, block_theme: bool, exempt_roles: list, settings: list>}

jpkcom_harden_trim_status_late_constant()

A core constant defined after the plugin's load-time snapshot that keeps an active setting from acting.

jpkcom_harden_trim_status_late_constant(string $key, mixed $value, array{name: string, value: mixed}|null $core) : array{name: string, value: mixed}|null

file_edit and autosave_interval work by defining DISALLOW_FILE_EDIT and AUTOSAVE_INTERVAL on plugins_loaded, and skip when the constant already exists (features-security.php, features-performance.php). A constant defined by another plugin's file body comes after the snapshot but before that, so it is no core lock and still wins. Only an active value counts: core defines AUTOSAVE_INTERVAL itself when the plugin does not, and the plugin's own definition equals the setting.

Parameters
$key : string

Setting key.

$value : mixed

Effective value.

$core : array{name: string, value: mixed}|null

Core lock, if any.

Tags
since
1.2.0
Return values
array{name: string, value: mixed}|null —

The winning constant, or null.

jpkcom_harden_trim_status_scalar()

A core constant's value as a JSON scalar.

jpkcom_harden_trim_status_scalar(mixed $value) : bool|int|float|string|null

wp-config.php may define anything; arrays and objects are reported as their type name rather than passed through.

Parameters
$value : mixed

Constant value.

Tags
since
1.2.0
Return values
bool|int|float|string|null
On this page

Search results