'attachment',
'post_mime_type' => 'image',
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'ASC',
]);
if (!empty($logos)) {
$logo_id = $logos[0]->ID;
}
}
$cached_id = $logo_id ? intval($logo_id) : 0;
return $cached_id;
}
function unfia_logo($size = 'full', $class = 'unfia-logo-img') {
$logo_id = unfia_get_logo_id();
if ($logo_id) {
echo wp_get_attachment_image($logo_id, $size, '', ['class' => $class, 'alt' => get_bloginfo('name')]);
} else {
echo '' . get_bloginfo('name') . '';
}
}
function unfia_get_image($size = 'full', $class = 'img-fluid', $attachment_id = 0) {
if ($attachment_id) {
return wp_get_attachment_image($attachment_id, $size, false, ['class' => $class, 'alt' => get_bloginfo('name')]);
}
$images = get_posts([
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'ASC',
]);
if (!empty($images)) {
return wp_get_attachment_image($images[0]->ID, $size, false, ['class' => $class, 'alt' => get_bloginfo('name')]);
}
return '
';
}
function unfia_get_attachment_url_by_filename($filename) {
$attachments = get_posts([
'post_type' => 'attachment',
'posts_per_page' => 1,
'meta_query' => [['key' => '_wp_attached_file', 'value' => $filename, 'compare' => 'LIKE']],
]);
if (!empty($attachments)) {
return wp_get_attachment_url($attachments[0]->ID);
}
return UNFIA_URI . '/assets/images/placeholder-about.jpg';
}
function unfia_get_image_html($filename, $size = 'full', $class = 'img-fluid', $alt = '') {
$url = unfia_get_attachment_url_by_filename($filename);
return '';
}
function unfia_social_icons() {
$socials = ['facebook', 'twitter', 'instagram', 'linkedin', 'youtube', 'tiktok'];
foreach ($socials as $s) {
$url = unfia_get_option($s . '_url');
if ($url) {
$icon = 'facebook' === $s ? 'facebook-f' : $s;
echo '';
}
}
}
function unfia_whatsapp_link($type = 'usa') {
$usa = unfia_get_option('whatsapp_usa', '+13073939042');
$sri = unfia_get_option('whatsapp_sri', '94772305309');
$num = 'usa' === $type ? $usa : $sri;
$clean = preg_replace('/[^0-9]/', '', $num);
return 'https://wa.me/' . $clean;
}
function unfia_phone_numbers() {
$usa = unfia_get_option('whatsapp_usa', '+1 (307) 393-9042');
$sri = unfia_get_option('whatsapp_sri', '+94 772305309');
return [$usa, $sri];
}
function unfia_email() {
return unfia_get_option('contact_email', 'ranjithopatha@gmail.com');
}
function unfia_breadcrumbs() {
if (is_front_page()) return;
echo '';
}
function unfia_pagination() {
global $wp_query;
$big = 999999999;
$pages = paginate_links([
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => '',
'next_text' => '',
]);
if (is_array($pages)) {
echo '';
}
}
function unfia_excerpt($limit = 30) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt) >= $limit) {
array_pop($excerpt);
$excerpt = implode(' ', $excerpt) . '...';
} else {
$excerpt = implode(' ', $excerpt);
}
$excerpt = preg_replace('`[[^]]*]`', '', $excerpt);
return $excerpt;
}
function unfia_section_title($title, $subtitle = '', $class = '') {
?>