Created
April 28, 2017 08:26
-
-
Save Khaled56/043811ea354c0087ee325e077c646b7d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 service_box_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'title'=> '', | |
'desc' => '', | |
'type' => 1, | |
'link_to_page' => '', | |
'link_to_external' => '', | |
'link_text' => 'See More', | |
'icon_type' => 1, | |
'upload_icon' => '', | |
'choose_icon' => '', | |
'box_bg' => '', | |
), $atts) ); | |
if( $type == 1 ){ | |
$link_source = get_page_link($link_to_page); | |
} else { | |
$link_source = $link_to_external; | |
} | |
$box_bg_array = wp_get_attachment_image_src($box_bg, 'medium'); | |
$service_box_markup = ' | |
<div class="service-box"> | |
<div style="background-image:url('.$box_bg_array[0].')" class="service-icon"> | |
<div class="service-table"> | |
<div class="service-tablecell"> '; | |
if( $icon_type == 1 ){ | |
$service_icon_array = wp_get_attachment_image_src($upload_icon, 'thumbnail'); | |
$service_box_markup .= '<img src="'.$service_icon_array[0].'" alt="" />'; | |
} else { | |
$service_box_markup .= '<i class="'.$choose_icon.'"></i>'; | |
} | |
$service_box_markup .= ' | |
</div> | |
</div> | |
</div> | |
<div class="service-content"> | |
<h3>'.$title.'</h3> | |
'.wpautop($desc).' | |
<a href="'.$link_source.'" class="service-btn">'.$link_text.'</a> | |
</div> | |
</div> | |
'; | |
$service_box_markup .= ''; | |
return $service_box_markup; | |
} | |
add_shortcode('service_box', 'service_box_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment