File: /home/globfdxw/diasporameetsafrica.com/wp-content/themes/DA10/templates/tpl-page-countries.php
<?php
/*
Template Name: [PAGE - COUNTRY]
*/
if (!defined('THEME_VERSION')) { header('HTTP/1.0 403 Forbidden'); exit; }
$GLOBALS['flag-country'] = 1;
global $userdata, $CORE;
$pageLinkingID = _ppt_pagelinking("country");
if( substr($pageLinkingID ,0,9) == "elementor" ){
get_header();
echo do_shortcode( "[premiumpress_elementor_template id='".substr($pageLinkingID,10,100)."']");
get_footer();
die();
}else{
get_header();
_ppt_template( 'page-before' );
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
$termdata = get_terms( [
'taxonomy' => array('country'),
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
'number' => 1000,
'parent' => 0,
]);
$total_cats = count($termdata);
$categoryList = array();
$i=1; $sf = 0;
foreach ($termdata as $term) {
$categoryList[$term->term_id] = array("id" => $term->term_id, "name" => $term->name, "slug" => $term->slug, "data" => array(), "count" => $term->count );
}
foreach ($termdata as $term) {
$cityArray = array();
$stateArray = array();
$citydata = get_terms( [
'taxonomy' => array('country'),
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
'parent' => $term->term_id,
'number' => 1000,
]);
if(!empty($citydata)){
foreach ($citydata as $cd) {
$subdata = array();
$citydata1 = get_terms( [
'taxonomy' => array('country'),
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
'parent' => $cd->term_id,
'number' => 1000,
]);
if(!empty($citydata1)){
foreach ($citydata1 as $cd1) {
$subdata[] = array("id" => $cd1->term_id, "name" => $cd1->name, "slug" => $cd1->slug, "count" => $cd1->count );
}
}
$cityArray[] = array("id" => $cd->term_id, "name" => $cd->name, "slug" => $cd->slug, "count" => $cd->count, "data" => $subdata );
$categoryList[$term->term_id]['data'] = $cityArray;
}
}
}
$total_parent_cats = count($categoryList);
$letters = range('A', 'Z');
$showmmorethan = 40;
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
?>
<div class="bg-white">
<div class="container py-4">
<div class="row">
<?php
$termdata = get_terms('country', 'orderby=count&order=desc&hide_empty=0&number=30&parent=0');
$total_merchants = count($termdata);
$i=1; $sf = 0;
foreach ($termdata as $term) {
// LINK
$link = get_term_link($term);
?>
<div class="col-lg-3 col-md-4 col-4 col-lg-5ths">
<div class="card shadow-sm mb-md-4 card-mobile-transparent">
<div class="card-body text-center card-hover">
<a href="<?php echo $link; ?>" class="text-decoration-none text-dark">
<div class="row">
<div class="col-12 col-md-12">
<span class="flag <?php echo $CORE->GEO("get_flagicon_from_name", array($term->name, $GLOBALS['core_country_list_new'])); ?>"></span>
</div>
<div class="col-12 col-md-12">
<div class="icon-text text-600 overflow-ellipsis"><?php echo $CORE->GEO("translation_tax", array($term->id, $term->name)) ; ?></div>
<div class="small opacity-5"><?php echo $term->count; ?> <?php echo __("found","premiumpress"); ?></div>
</div>
</div>
</a>
</div>
</div>
</div>
<?php $i++; } ?>
</div>
</div></div>
<?php
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
?>
<div class="border-bottom border-top">
<div class="container py-4">
<p class="mt-2 opacity-5"><?php echo __("List of all locations.","premiumpress") ?></p>
<div class="d-flex justify-content-between mt-4 tablist hide-mobile">
<div class="tab tab-all active"><a href="javascript:void(0);" onclick="filterLetters('all');"><?php echo __("All","premiumpress") ?></a></div>
<?php foreach($letters as $l){ ?>
<div class="tab tab-<?php echo $l; ?>"><a href="javascript:void(0);" onclick="filterLetters('<?php echo $l; ?>');"><?php echo $l; ?></a></div>
<?php } ?>
</div>
</div>
</div>
<div class="bg-white">
<div class="container py-4">
<?php
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
?>
<?php foreach($letters as $l){ ?>
<div class="wrap wrap-<?php echo $l; ?>" id="<?php echo $l; ?>">
<h3><?php echo $l; ?></h3>
<hr />
<div class="row ">
<?php $i =1; foreach($categoryList as $catid => $catdata){ ?>
<?php if(substr(strtolower($catdata['name']), 0,1) == strtolower($l)){ ?>
<div class="col-md-4">
<div class="clearfix mb-3" data-topcatid="<?php echo $catid; ?>">
<div class="fs-5 <?php if($catdata['count'] > 0){ ?>text-600<?php } ?>">
<a href="<?php echo get_term_link($catdata['slug'], "country"); ?>" class="text-dark">
<span class="flag <?php echo $CORE->GEO("get_flagicon_from_name", array($catdata['name'], $GLOBALS['core_country_list_new'])); ?>"></span>
<span class="ml-2"><?php echo $CORE->GEO("translation_tax", array($catdata['id'], $catdata['name'])); ?> <span class="<?php if($catdata['count'] > 0){ }else{ ?>small opacity-5<?php } ?>">(<?php echo $catdata['count']; ?>)</span></span>
</a>
</div>
</div>
<?php if(isset($catdata['data']) && !empty($catdata['data'])){ ?>
</div><div class="col-12"><div class="row small">
<?php foreach($catdata['data'] as $subcat){ ?>
<div class="col-6 col-md-4 py-2 mobile-text-12">
<a href="<?php echo get_term_link($subcat['slug'], "country"); ?>" class="text-dark">
<?php echo $CORE->GEO("translation_tax", array($subcat['id'], $subcat['name'])); ?>
</a>
<span class="<?php if($subcat['count'] > 0){ }else{ ?>small opacity-5<?php } ?>">
(<?php echo $subcat['count']; ?>)
</span>
<?php if(isset($subcat['data']) && !empty($subcat['data'])){ ?>
<div class="mt-2">
<?php foreach($subcat['data'] as $city){ ?>
<span> ·
<a href="<?php echo get_term_link($city['slug'], "country"); ?>" class="text-dark">
<?php echo $CORE->GEO("translation_tax", array($city['id'], $city['name'])); ?>
</a>
<span class="<?php if($city['count'] > 0){ }else{ ?>small opacity-5<?php } ?>">
(<?php echo $city['count']; ?>)
</span>
</span>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
</div></div>
<div>
<?php } ?>
</div>
<?php $i++; } ?>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>
<style>
.tablist .tab { padding: 5px 15px; }
.tablist .tab.active { background:#111; border-radius:4px; }
.tablist .tab.active a { color:#fff; font-weight:bold; }
.bg-image-wrap { height:130px; width:100%; border-radius:4px; position:relative; background: #fff; border: 1px solid #ddd; }
.bg-image-wrap .bg-image { background-size: unset; background-repeat: no-repeat; }
.overflow-ellipsis {max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: inline-block; }}
@media (max-width: 575.98px) {
.bg-image-wrap { height:100px; }
.bg-image-wrap .bg-image {
background-size: contain;
}
}
</style>
<script>
function filterLetters(l){
jQuery(".tab").removeClass('active');
jQuery(".tab-"+l).addClass('active');
if(l == "all"){
jQuery(".wrap").show();
cleanCats();
}else{
jQuery(".wrap").hide();
jQuery(".wrap-"+l).show();
}
}
function filterCategory(l){
if(l == "all"){
jQuery(".wrap").show();
cleanCats();
}else{
jQuery(".wrap").hide();
jQuery(".hascat-"+l).show();
}
}
function cleanCats(){
var a = jQuery(".wrap");
a.each(function (a) {
wrapid = jQuery(this).attr('id').toString();
var a = jQuery(".wrap-"+wrapid+" .category-wrap");
a.each(function (a) {
topid = jQuery(this).attr('data-topcatid');
jQuery('.wrap-'+wrapid+'').addClass(" hascat-"+topid)
});
links = jQuery('.wrap-'+wrapid+' a').length;
if(links == 0){
jQuery(this).hide();
jQuery('.tablist').removeClass('justify-content-between');
jQuery(".tab-"+wrapid).hide();
}
});
}
jQuery(document).ready(function(){
cleanCats();
});
</script>
<?php
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
_ppt_template( 'page-after' );
get_footer();
} ?>