-
-
Save annelyse/4dead37c4ef9142a62a29da6c744758e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// display title | |
if (!function_exists('display_title_acf')) { | |
function display_title_acf($title = '', $tag = "h2", $class = '') | |
{ | |
if (!empty($title)) { | |
echo '<' . $tag . ' class="title ' . $class . '">' . $title . '</' . $tag . '>'; | |
} | |
} | |
} | |
if (!function_exists('display_text_acf')) { | |
function display_text_acf($text = '') | |
{ | |
if (!empty($text)) { | |
echo '<p>' . $text . '</p>'; | |
} | |
} | |
} | |
if (!function_exists('display_link_acf')) { | |
function display_link_acf($link, $target = null, $class = null, $content = null) | |
{ | |
if (!empty($link)) { | |
// url | |
if (isset($link['url'])) { | |
$url = $link['url']; | |
} else { | |
$url = $link; | |
} | |
//target | |
if (isset($link['target']) && !empty($link['target'])) { | |
$target = $link['target']; | |
} elseif (empty($target)) { | |
$target = "_self"; | |
} | |
$rel = ""; | |
if ($target == "_blank") { | |
$rel = 'rel="noopener"'; | |
} | |
//class | |
if (empty($class)) { | |
$class = "btn-outline-secondary"; | |
} | |
// content | |
if (isset($link['title']) && !empty($link['title'])) { | |
$content = $link['title']; | |
} elseif (empty($content)) { | |
$content = __('En savoir plus', config('textdomain')); | |
} | |
echo '<div class="btn-container text-center"><a class="btn ' . $class . '" ' . $rel . ' href="' . esc_url($url) . '" target="' . $target . '">' . esc_html($content) . '</a></div>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment