<?php if (!defined('ABSPATH')) { exit; } if (!class_exists('acf_fields')) { class acf_fields { var $types = array(); function __construct() { } function register_field_type($class) { if ($class instanceof acf_field) { $this->types[$class->name] = $class; } else { $instance = new $class(); $this->types[$instance->name] = $instance; } } function get_field_type($name) { return isset($this->types[$name]) ? $this->types[$name] : null; } function is_field_type($name) { return isset($this->types[$name]); } function register_field_type_info($info) { $instance = (object) $info; $this->types[$instance->name] = $instance; } function get_field_types() { return $this->types; } } acf()->fields = new acf_fields(); } function acf_register_field_type($class) { return acf()->fields->register_field_type($class); } function acf_register_field_type_info($info) { return acf()->fields->register_field_type_info($info); } function acf_get_field_type($name) { return acf()->fields->get_field_type($name); } function acf_get_field_types($args = array()) { $args = wp_parse_args($args, array('public' => true)); $field_types = acf()->fields->get_field_types(); return wp_filter_object_list($field_types, $args); } function acf_get_field_types_info($args = array()) { $data = array(); $field_types = acf_get_field_types(); foreach ($field_types as $type) { $data[$type->name] = array('label' => $type->label, 'name' => $type->name, 'category' => $type->category, 'public' => $type->public); } return $data; } function acf_is_field_type($name = '') { return acf()->fields->is_field_type($name); } function acf_get_field_type_prop($name = '', $prop = '') { $type = acf_get_field_type($name); return $type && isset($type->{$prop}) ? $type->{$prop} : null; } function acf_get_field_type_label($name = '') { $label = acf_get_field_type_prop($name, 'label'); return $label ? $label : '<span class="acf-tooltip-js" title="' . __('Field type does not exist', 'acf') . '">' . __('Unknown', 'acf') . '</span>'; } function acf_field_type_exists($type = '') { return acf_is_field_type($type); } function acf_get_grouped_field_types() { $types = acf_get_field_types(); $groups = array(); $l10n = array('basic' => __('Basic', 'acf'), 'content' => __('Content', 'acf'), 'choice' => __('Choice', 'acf'), 'relational' => __('Relational', 'acf'), 'jquery' => __('jQuery', 'acf'), 'layout' => __('Layout', 'acf')); foreach ($types as $type) { $cat = $type->category; $cat = isset($l10n[$cat]) ? $l10n[$cat] : $cat; $groups[$cat][$type->name] = $type->label; } $groups = apply_filters('acf/get_field_types', $groups); return $groups; }