Skip to content

Instantly share code, notes, and snippets.

@hasanm95
Created September 9, 2017 17:52
Show Gist options
  • Save hasanm95/8fb6b42991e275f8154223a231bb72aa to your computer and use it in GitHub Desktop.
Save hasanm95/8fb6b42991e275f8154223a231bb72aa to your computer and use it in GitHub Desktop.
Industry service box 2
//Kc addon code
kc_add_map(
array(
'industry_servic_box2' => array(
'name' => 'Service Box2',
'description' => __('Use this addon for service box', 'KingComposer'),
'icon' => 'sl-paper-plane',
'category' => 'Industry',
'params' => array(
array(
'name' => 'img',
'label' => 'Upload Icon',
'type' => 'attach_image',
'description' => 'Upload service box image',
),
array(
'name' => 'title',
'label' => 'Title',
'type' => 'text',
'description' => 'Type section title',
),
array(
'name' => 'description',
'label' => 'Description',
'type' => 'textarea',
'description' => 'Type section Description',
),
array(
'name' => 'link',
'label' => 'Link',
'type' => 'link',
'description' => 'Select section Link',
)
)
), // End of elemnt kc_icon
)
); // End add map
//Shortcode
function industry_servic_box_shortcode2($atts){
extract(shortcode_atts(array(
'img' => '',
'title' => '',
'description' => '',
'link' => '',
),$atts));
$industry_servic_box_markup2 = '<div class="industry-service-box-2">';
$service_icon_image_array = wp_get_attachment_image_src($img, 'large');
$industry_servic_box_markup2 .= '<div class="service-box-img">
<img src="'.esc_url($service_icon_image_array[0]).'" alt="'.esc_html($title).'">
</div>';
if(!empty($title)){
$industry_servic_box_markup2 .= '<h2>'.esc_html($title).'</h2>';
}
if(!empty($description)){
$industry_servic_box_markup2 .= wpautop(esc_html($description));
}
if(!empty($link)){
$link_array = explode('|', $link);
$industry_servic_box_markup2 .= '<a href="'.$link_array[0].'" target="'.$link_array[2].'" class="boxed-btn">'.$link_array[1].'</a>';
}
$industry_servic_box_markup2 .= '</div>';
return $industry_servic_box_markup2;
}
add_shortcode('industry_servic_box2', 'industry_servic_box_shortcode2');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment