Skip to content

Instantly share code, notes, and snippets.

@Khaled56
Created April 28, 2017 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Khaled56/043811ea354c0087ee325e077c646b7d to your computer and use it in GitHub Desktop.
Save Khaled56/043811ea354c0087ee325e077c646b7d to your computer and use it in GitHub Desktop.
<?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