acf
This commit is contained in:
88
plugins/fields/acfurl/tmpl/acfurl.php
Normal file
88
plugins/fields/acfurl/tmpl/acfurl.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
if (!$url = $field->value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$url = new Registry($url);
|
||||
|
||||
if (empty($url['url']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$id = 'acf_url_' . $item->id . '_' . $field->id;
|
||||
|
||||
// Output
|
||||
$rel = [];
|
||||
$CSSClass = trim('acf_url ' . $fieldParams->get('url_class'));
|
||||
$buffer = '<a id="' . $id . '" href="' . $url->get('url') . '" class="' . $CSSClass . '"';
|
||||
$noopener = $fieldParams->get('noopener', '1') === '1';
|
||||
|
||||
// Add noopener rel attribute
|
||||
$rel = array_merge($rel, [
|
||||
'noopener' => $noopener
|
||||
]);
|
||||
|
||||
// Set target attribute
|
||||
if ($url->get('target') == 'new_tab')
|
||||
{
|
||||
$buffer .= ' target="_blank"';
|
||||
|
||||
// Force it on new_tab links
|
||||
$rel = array_merge($rel, [
|
||||
'noopener' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
if ($url->get('target') == 'popup')
|
||||
{
|
||||
$onclick = $fieldParams->get('onclick');
|
||||
$new_window_code = 'window.open(\'' . $url->get('url') . '\', \'_blank\', \'width=800,height=600\'); return false;';
|
||||
$fieldParams->set('onclick', $onclick . $new_window_code);
|
||||
}
|
||||
|
||||
// Set the onClick handler - Do not remove this block from Free version as it's required by the target property.
|
||||
$onclick = $fieldParams->get('onclick');
|
||||
if (!empty($onclick)) {
|
||||
$buffer .= ' onclick="' . $onclick . '"';
|
||||
}
|
||||
|
||||
|
||||
// Set rel attributes
|
||||
$rel = array_filter(array_merge($rel, [
|
||||
'noreferrer' => $fieldParams->get('noreferrer', false),
|
||||
'nofollow' => $fieldParams->get('nofollow', false)
|
||||
]));
|
||||
|
||||
// Treat it as a download link
|
||||
if ($fieldParams->get('treat_as_download_link', false))
|
||||
{
|
||||
$buffer .= ' download';
|
||||
}
|
||||
|
||||
|
||||
if ($rel)
|
||||
{
|
||||
$buffer .= ' rel="' . implode(' ', array_keys($rel)) . '"';
|
||||
}
|
||||
|
||||
$buffer .= '>' . Text::_($url->get('text', $fieldParams->get('default_text'))) . '</a>';
|
||||
|
||||
echo $buffer;
|
||||
Reference in New Issue
Block a user