acf = $acf;
$this->fieldMeta = $fieldMeta;
$this->field = $field;
$this->fieldValue = $fieldValue;
}
protected function getImageMarkup(): string
{
$imageUrl = '';
switch ($this->fieldMeta->getReturnFormat()) {
case 'id':
$imageUrl = function_exists('wp_get_attachment_image_url') ?
(string)wp_get_attachment_image_url($this->fieldValue, 'full') :
'';
break;
case 'array':
$imageUrl = (is_array($this->fieldValue) &&
key_exists('url', $this->fieldValue)) ?
$this->fieldValue['url'] :
'';
break;
case 'url':
$imageUrl = $this->fieldValue;
break;
}
return "";
}
protected function getFileMarkup(): string
{
$fileUrl = '';
$fileTitle = '';
switch ($this->fieldMeta->getReturnFormat()) {
case 'id':
$fileUrl = function_exists('wp_get_attachment_url') ?
(string)wp_get_attachment_url($this->fieldValue) :
'';
$fileTitle = (! $this->field->label &&
function_exists('get_post')) ?
(get_post($this->fieldValue)->post_title ?? '') :
$this->field->label;
break;
case 'array':
$fileUrl = $this->fieldValue['url'] ?? '';
$fileTitle = ! $this->field->label ?
($this->fieldValue['title'] ?? '') :
$this->field->label;
break;
case 'url':
$fileUrl = $this->fieldValue;
$fileTitle = $this->field->label ?: $fileUrl;
break;
}
return "" . esc_html($fileTitle) . "";
}
protected function getSelectMarkup(): string
{
$fieldHTML = '';
// select & checkbox could have multiple values
$fieldValues = (is_array($this->fieldValue) &&
! key_exists('label', $this->fieldValue)) ?
$this->fieldValue :
[$this->fieldValue];
$fieldViews = [];
foreach ($fieldValues as $fieldValue) {
switch ($this->fieldMeta->getReturnFormat()) {
case 'value':
$fieldViews[] = $this->fieldMeta->getChoices()[$fieldValue] ?? '';
break;
case 'label':
$fieldViews[] = $fieldValue;
break;
case 'array':
$fieldViews[] = $fieldValue['label'] ?? '';
break;
}
}
if ('radio' === $this->fieldMeta->getType()) {
return implode('', $fieldViews);
}
foreach ($fieldViews as $subFieldView) {
$fieldHTML .= "