# Plugin Options

Imports bulk plugin configuration options from `plugin_options.json`. This file is
generated by `bin/site-export.sh` and contains all wp_options not already managed
by other state modules (base, plugins, theme, menus, etc.).

Imposer's built-in option patching handles the actual `update_option()` calls,
including recursive merge for complex array/object values.

## Load plugin options from JSON

```shell
# Only load if the JSON file exists and is non-empty.
# Uses JQ_OPTS --slurpfile to avoid ARG_MAX limits on large option sets.
PLUGIN_OPTS_FILE="imposer/plugin_options.json"
if [ -f "$PLUGIN_OPTS_FILE" ] && [ -s "$PLUGIN_OPTS_FILE" ]; then
  JQ_OPTS --slurpfile plugin_opts_raw "$PLUGIN_OPTS_FILE"
else
  ARGJSON plugin_opts_raw '[{}]'
fi
```

Merge all plugin options into the specification. Values marked `"__REDACTED__"` are
stripped so they don't overwrite existing credentials on the target.

```jq
# Recursively strip __REDACTED__ sentinel values at any nesting depth.
# This preserves the structure of partially-redacted options (e.g., wp_mail_smtp
# has credentials redacted but from_email/mailer config preserved).
def strip_redacted:
  if type == "object" then
    to_entries
    | map(select(.value != "__REDACTED__") | .value |= strip_redacted)
    | from_entries
  elif type == "array" then
    map(if . == "__REDACTED__" then empty else strip_redacted end)
  else .
  end;

($plugin_opts_raw[0] | strip_redacted) as $clean
| .options = ((.options // {}) * $clean)
```

## Exclude noisy options from imposer diff

These options change frequently and would generate noise in `imposer options review`.

```shell
exclude-options cron rewrite_rules recently_activated active_plugins template stylesheet current_theme
```
