plugin install
This commit is contained in:
@@ -22,36 +22,31 @@ if ( ! class_exists( 'acf_fields' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function will register a field type instance
|
||||
* This function will register a field type instance based on a class name or instance.
|
||||
* It will return the instance for further use.
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $class (string)
|
||||
* @return n/a
|
||||
* @param mixed $field_class Either a class name (string) or instance of acf_field.
|
||||
* @return acf_field The instance of acf_field.
|
||||
*/
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return a field type instance
|
||||
@@ -63,7 +58,6 @@ if ( ! class_exists( 'acf_fields' ) ) :
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_field_type( $name ) {
|
||||
return isset( $this->types[ $name ] ) ? $this->types[ $name ] : null;
|
||||
}
|
||||
@@ -79,7 +73,6 @@ if ( ! class_exists( 'acf_fields' ) ) :
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function is_field_type( $name ) {
|
||||
return isset( $this->types[ $name ] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user