class acf_fields {
/** @var array Contains an array of field type instances */
var $types = array();
/*
* __construct
*
* This function will setup the class functionality
*
* @type function
* @date 5/03/2014
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function __construct() {
/* do nothing */
}
/*
* register_field_type
*
* This function will register a field type instance
*
* @type function
* @date 6/07/2016
* @since 5.4.0
*
* @param $class (string)
* @return n/a
*/
function register_field_type( $class ) {
// allow instance
if ( $class instanceof acf_field ) {
$this->types[ $class->name ] = $class;
// allow class name
} else {
$instance = new $class();
$this->types[ $instance->name ] = $instance;
}
}
/*
* get_field_type
*
* This function will return a field type instance
*
* @type function
* @date 6/07/2016
* @since 5.4.0
*
* @param $name (string)
* @return (mixed)
*/
function get_field_type( $name ) {
return isset( $this->types[ $name ] ) ? $this->types[ $name ] : null;
}
/*
* is_field_type
*
* This function will return true if a field type exists
*
* @type function
* @date 6/07/2016
* @since 5.4.0
*
* @param $name (string)
* @return (mixed)
*/
function is_field_type( $name ) {
return isset( $this->types[ $name ] );
}
/*
* register_field_type_info
*
* This function will store a basic array of info about the field type
* to later be overriden by the above register_field_type function
*
* @type function
* @date 29/5/17
* @since 5.6.0
*
* @param $info (array)
* @return n/a
*/
function register_field_type_info( $info ) {
// convert to object
$instance = (object) $info;
$this->types[ $instance->name ] = $instance;
}
/*
* get_field_types
*
* This function will return an array of all field types
*
* @type function
* @date 6/07/2016
* @since 5.4.0
*
* @param $name (string)
* @return (mixed)
*/
function get_field_types() {
return $this->types;
}
}