Created
August 2, 2018 05:35
-
-
Save humayunahmed8/614810c8f6b92771724ff251e61fdeb1 to your computer and use it in GitHub Desktop.
Service box shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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