<?php
/**
 * Created by Sublime text 2.
 * User: thanhhiep992
 * Date: 12/08/15
 * Time: 10:00 AM
 */

if(!function_exists('sv_vc_social'))
{
    function sv_vc_social($attr, $content = false)
    {
        $html = $icon_html = '';
        extract(shortcode_atts(array(
            'style'         => 'home-1',
            'list'          => '',
            'align'         => 'text-left',
        ),$attr));
		parse_str( urldecode( $list ), $data);
        if(is_array($data)){
            foreach ($data as $key => $value) {
                $url = '#';
                if(isset($value['url'])) $url = $value['url'];
                $icon_html .= '<li><a href="'.esc_url($url).'"><i class="fa '.$value['social'].'"></i></a></li>';
            }
        }
        $html .=    '<div class="block-social '.$style.' '.$align.'">
                        <ul class="list-social">';                        
        $html .=            $icon_html;   
        $html .=        '</ul>
                    </div>';   
		return  $html;
    }
}

stp_reg_shortcode('sv_social','sv_vc_social');


vc_map( array(
    "name"      => esc_html__("SV Social", 'megastore'),
    "base"      => "sv_social",
    "icon"      => "icon-st",
    "category"  => '7Up-theme',
    "params"    => array(
        array(
            'type'        => 'dropdown',
            'heading'     => esc_html__( 'Style', 'megastore' ),
            'param_name'  => 'style',
            'value'       => array(
                esc_html__( 'Home 1', 'megastore' )   => 'home-1',
                esc_html__( 'Home 2', 'megastore' )   => 'home-2',
                )
        ),
        array(
			'type' => 'dropdown',
			'heading' => esc_html__( 'Align', 'megastore' ),
			'value' => array(
				esc_html__( 'Align Left', 'megastore' ) => 'text-left',
				esc_html__( 'Align Center', 'megastore' ) => 'text-center',
				esc_html__( 'Align Right', 'megastore' ) => 'text-right',
			),
			'param_name' => 'align',
			'description' => esc_html__( 'Select social layout', 'megastore' ),
		),
		array(
            "type" => "add_social",
            "heading" => esc_html__("Add Social List",'megastore'),
            "param_name" => "list",
        )
    )
));