<?php
/**
 * Created by PhpStorm.
 * User: adiardana
 * Date: 02/05/19
 * Time: 01.18
 */
add_shortcode('social_media', function(){
    $socials = get_field('social_media', 'option');
    if(!$socials) return;
    $html = '<ul class="social-media-list">';
    foreach ($socials as $social) {
        $html .= '<li class="icon icon-'.$social['account'].'"><a href="'.$social['url'].'" title="'.$social['account'].'" target="_blank">';
        switch ($social['account']){
            case 'facebook':
                $html .= '<i class="fa fa-facebook" aria-hidden="true"></i>';
                break;
            case 'twitter':
                $html .= '<i class="fa fa-twitter" aria-hidden="true"></i>';
                break;
            case 'instagram':
                $html .= '<i class="fa fa-instagram" aria-hidden="true"></i>';
                break;
            case 'linkedin':
                $html .= '<i class="fa fa-linkedin" aria-hidden="true"></i>';
                break;
            case 'youtube':
                $html .= '<i class="fa fa-youtube-play" aria-hidden="true"></i>';
                break;
        }
        $html .= '<svg xmlns="http://www.w3.org/2000/svg" width="40" height="46" viewBox="0 0 61 70"  preserveAspectRatio="none"><metadata><?xpacket begin="﻿" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c138 79.159824, 2016/09/14-01:09:01        "><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about=""/></rdf:RDF></x:xmpmeta><?xpacket end="w"?></metadata><defs></defs><path id="Polygon_1" data-name="Polygon 1" class="cls-1" d="M60.987,52.482L30.516,70,0.021,52.523,0,17.53,30.468,0.013l30.5,17.476Z"/></svg>';
        $html .= '</a></li>';
    }
    $html .= '</ul>';
    return $html;
});

add_shortcode('alt_logo', function(){
    $html = '';
   if(get_field('alt_logo', 'option')){
       $img = wp_get_attachment_image_url(get_field('alt_logo', 'option'), 'full');
       $html .= '<img class="alt-logo" src="'.$img.'"/>';
   }
   return $html;
});