cafe_register_field_type()
Purpose
Registers a custom field type so it can be used in field groups like a built-in type.
Syntax
cafe_register_field_type( Cybo\AdvancedFieldEngine\Fields\FieldTypeInterface|string $field_type ): bool
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$field_type |
FieldTypeInterface or class name |
- | An instance, or the name of a class implementing Cybo\AdvancedFieldEngine\Fields\FieldTypeInterface (usually extending Cybo\AdvancedFieldEngine\Fields\AbstractFieldType). |
Return value
true when registered. false (with a _doing_it_wrong() notice) when the class does not
implement the interface, the name is invalid or already taken (core names cannot be
replaced), or the category is unknown.
Example
add_action( 'cafe_register_field_types', function () {
cafe_register_field_type( Icon_Picker_Field::class );
} );
Notes
- Register before fields of that type are read or saved:
cafe_register_field_types,plugins_loadedorinitare all fine. - Full guide: Custom field types.