All features

Cherry Blossom feature

ACF: Preset

Represents a reusable choice preset for supported ACF field types.

Represents a reusable choice preset for supported ACF field types.

Capabilities and extension points

Represents a reusable choice preset for supported ACF field types.

Choices and the default value may be static or resolved lazily through callbacks. Projects can further filter choices through the handle-specific cherry/blossom/acf/preset/options/{handle} filter.

Creates a preset.

  • param string $handle Stable preset identifier.
  • param string $label Human-readable label shown in ACF field settings.

Sets static choices or a callback that returns choices.

The callback receives no arguments and must return an array keyed by stored field value. Callback storage currently accepts only function names and callable arrays; Closure and invokable objects cause a TypeError.

  • param array|callable $options Choice map or lazy choice callback.

Gets the filtered preset choices.

  • return array Choices keyed by stored field value.

Gets the preset's default field value.

  • return mixed Default value, or null when none is configured.

Sets the callback used to resolve the default value.

The callback receives no arguments. Use a function name or callable array; current property types reject Closure and invokable objects.

  • param callable $callback Default-value callback.

Gets the preset label.

  • return string Human-readable preset label.

Determines whether the active preset supports an ACF field type.

  • param string $type ACF field type.
  • return bool Whether the preset is available for the field type.

Resolves backward-compatible computed properties.

  • param string $param Property name.
  • return mixed Computed property value, or null when unsupported.

Sets backward-compatible computed properties.

  • param string $param Property name.
  • param mixed $value Property value.
  • return null Magic setter return value.

Source reference

This editable reference page is based on the PHP documentation in plugins/advanced-custom-fields/class-preset.php.