* @link http://www.tassos.gr * @copyright Copyright © 2020 Tassos Marinos All Rights Reserved * @license GNU GPLv3 or later */ defined('_JEXEC') or die; use Joomla\CMS\Factory; JLoader::register('ACF_Field', JPATH_PLUGINS . '/system/acf/helper/plugin.php'); if (!class_exists('ACF_Field')) { Factory::getApplication()->enqueueMessage('Advanced Custom Fields System Plugin is missing', 'error'); return; } class PlgFieldsACFPayPal extends ACF_Field { /** * Override the field type * * @var string */ protected $overrideType = 'ACFPayPal'; /** * Update the label of the field in filters. * * @param \Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection $options * * @return \Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection */ public function onJFiltersOptionsAfterCreation(\Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection $options) { // Make sure it is a field of that type if ($options->getFilterItem()->getAttributes()->get('type') !== $this->_name) { return $options; } foreach ($options as $option) { $optionData = $option->getData(); $value = is_string($optionData->value) ? json_decode($optionData->value, true) : $optionData->value; if (!is_array($value) || !isset($value['item_name']) || empty($value['item_name'])) { continue; } $option->setLabel($value['item_name']); } return $options; } }