acf_fields::register_field_type
This function will register a field type instance based on a class name or instance. It will return the instance for further use.
Method of the class: acf_fields{}
No Hooks.
Returns
acf_field. The instance of acf_field.
Usage
$acf_fields = new acf_fields(); $acf_fields->register_field_type( $field_class );
- $field_class(mixed) (required)
- Either a class name (string) or instance of acf_field.
Changelog
| Since 5.4.0 | Introduced. |
acf_fields::register_field_type() acf fields::register field type code ACF 6.8.8
public function register_field_type( $field_class ) {
// Allow registering an instance.
if ( $field_class instanceof acf_field ) {
$this->types[ $field_class->name ] = $field_class;
return $field_class;
}
// Allow registering a loaded class name.
$instance = new $field_class();
$this->types[ $instance->name ] = $instance;
return $instance;
}