<?php
/**
 * Template part for displaying single post Link hero content
 */
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

$link_url = get_post_meta( get_the_ID(),'rivax_single_link_url', true);
$link_title = get_post_meta( get_the_ID(),'rivax_single_link_title', true);
$link_url_text = preg_replace('/https?:\/\/(www.)?/', '', $link_url); // Remove http / www

echo '<div class="single-hero-link">';
if($link_url):
?>
    <div class="single-hero-link-container">
        <div class="link-content">
            <div class="icon">
                <span class="link-icon"><i class="ri-link"></i></span>
            </div>
            <div class="content">
                <span class="link"><?php echo esc_html($link_url_text); ?></span>
                <p class="title"><?php echo esc_html($link_title); ?></p>
            </div>
        </div>
        <a class="rivax-position-cover" target="_blank" href="<?php echo esc_url($link_url); ?>"></a>
    </div>
	<?php rivax_single_hero_caption () ?>
<?php
endif;
get_template_part('template-parts/post/hero/title-section');
echo '</div>'; // .single-hero-link
