Skip to content

Instantly share code, notes, and snippets.

@humayunahmed8
Created August 2, 2018 05:35
Show Gist options
  • Save humayunahmed8/614810c8f6b92771724ff251e61fdeb1 to your computer and use it in GitHub Desktop.
Save humayunahmed8/614810c8f6b92771724ff251e61fdeb1 to your computer and use it in GitHub Desktop.
Service box shortcode
<?php
function stock_service_box_shortcode($atts, $content = null){
extract( shortcode_atts( array(
'title' => '',
'desc' => '',
'type' => 1,
'link_to_page' => '',
'external_link' => '',
'link_text' => 'See more',
'icon_type' => 1,
'upload_icon' => '',
'choose_icon' => '',
'box_background' => '',
), $atts) );
if($type == 1){
$link_source = get_page_link($link_to_page);
}else{
$link_source = $external_link;
}
$box_bg_array = wp_get_attachment_image_src($upload_icon, 'medium');
$stock_service_box_markup = '
<div class="stock-service-box">
<div style="background-image: url('.$box_bg_array[0].')" class="stock-service-icon">
<div class="stock-service-table">
<div class="stock-service-tablecell">';
if ($icon_type == 1) {
$service_icon_array = wp_get_attachment_image_src($upload_icon, 'thumbnail');
$stock_service_box_markup .= '<img src="'.$service_icon_array[0].'" alt=""/>';
}else{
$stock_service_box_markup .= '<i class="'.$choose_icon.'"><i>';
}
$stock_service_box_markup .= '
</div>
</div>
</div>
<div class="stock-service-content">
<h3>'.$title.'</h3>
'.wpautop($desc).'
<a href="'.$link_source.'" class="service-more-btn">'.$link_text.'</a>
</div>
</div>
';
$stock_service_box_markup .= '';
return $stock_service_box_markup;
}
add_shortcode('stock_service_box', 'stock_service_box_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment