<?php
/*https://www.jqueryscript.net/demo/SocialCount-Mobile-Friendly-Social-Networking-Widgets/*/
$optres['css'][] = $path . 'amodules/social_media/widgets/like_buttons/like_buttons.css';
$optres['js'][] = $path . 'amodules/social_media/widgets/like_buttons/like_buttons.js';

// Get the actual URL
$is_online = true;
$ultra_domainname = $line_domain['domainname'];
$ultra_addonname = $line_domain['addonname'];
$current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

if(strpos($current_url, 'cypruswebsites') !== false) $is_online = false;

if(!$is_online) {
    $current_uri = str_replace($ultra_addonname, '', $_SERVER['REQUEST_URI']);
    $current_url = $protocol . $ultra_domainname . $current_uri;
}

$path_info = parse_url($current_url);
if(isset($path_info['query'])) {
    $remove_qs = false;
    if(strpos($path_info['query'], 'remove_cache') !== false) $remove_qs = true;
    if(strpos($path_info['query'], 'yp_renew') !== false) $remove_qs = true;
    if($remove_qs) {
        $current_url = rtrim(str_replace('?' . $path_info['query'], '', $current_url), '/');
    }
}

$show_container = true;
if(isset($params) && isset($params['show_container'])) {
    $show_container = $params['show_container'];
}

if($show_container) {
    ?>
    <div class="like-buttons">
        <?php
        if(isset($social_accounts['facebook'])) {
            ?>
            <div class="sm-facebook">
                <div class="fb-like" data-href="<?=$current_url;?>" data-layout="button_count" data-action="like" data-size="small" data-show-faces="true" data-share="false"></div>
            </div>
            <?php
        }

        ?>
    </div>
    <?php
}
else {
    if(isset($social_accounts['facebook'])) {
        ?>
        <div class="sm-facebook">
            <div class="fb-like" data-href="<?=$current_url;?>" data-layout="button_count" data-action="like" data-size="small" data-show-faces="true" data-share="false"></div>
        </div>
        <?php
    }
}
?>
