<?php
// [tm-static-contentbox]
if( !function_exists('themetechmount_sc_static_contentbox') ){
function themetechmount_sc_static_contentbox( $atts, $content=NULL ){
	
	$return = '';
	
	if( function_exists('vc_map') ){ 
	
	global $tm_vc_custom_element_staticcontent_box;
	$options_list = themetechmount_create_options_list($tm_vc_custom_element_staticcontent_box);
	
	extract( shortcode_atts(
		$options_list
	, $atts ) );
	

		
		
				
		// Starting wrapper of the whole arear
		$return .= themetechmount_box_wrapper( 'start', 'contentbox', get_defined_vars() );
		
		// Heading element
		$return .= themetechmount_vc_element_heading( get_defined_vars() );
	
		// Getting $args for WP_Query
		$args = themetechmount_get_query_args( 'contentbox', get_defined_vars() );
	
		if( !empty($box_content) ){
		
			$static_boxes = (array) vc_param_group_parse_atts( $box_content );

				
				$return .= '<div class="row multi-columns-row themetechmount-boxes-row-wrapper">';
				foreach( $static_boxes as $tm_box ){
					$staticbox_desc  = ( !empty($tm_box['static_boxcontent']) ) ? '<div class="tm-historybox-description">'.$tm_box['static_boxcontent'].'</div>' : '' ;
					
					
					$tm_box['static_boxlink']=( !empty($tm_box['static_boxlink']) ) ? $tm_box['static_boxlink'] : '';
					
					// Builing URL array
					$url =  themetechmount_vc_build_link($tm_box['static_boxlink']);
						
		
					$tm_bicon= do_shortcode('[tm-icon type="' . $tm_box['i_type'] . '" icon_linecons="' . $tm_box['i_icon_linecons'] . '" icon_themify="' . $tm_box['i_icon_themify'] . '" icon_fontawesome="' . $tm_box['i_icon_fontawesome'] . '" icon_kw_anomica="' . $tm_box['i_icon_kw_anomica'] . '" ]');
					
										
					$static_boxtitle      = ( !empty($tm_box['static_boxtitle']) ) ? '<div class="tm-box-title"><h4>'.$tm_box['static_boxtitle'].'</h4></div>' : '' ;
				
					$static_buttontitle      = ( !empty($tm_box['static_buttontitle']) ) ? '<div class="tm-box-Button-link"><h6>'.$tm_box['static_buttontitle'].'</h6></div>' : '' ;
							
					if ( strlen( $tm_box['static_boxlink'] ) > 0 && strlen( $url['url'] ) > 0 ) {
						
						$static_buttontitle      = ( !empty($tm_box['static_buttontitle']) ) ? '<div class="tm-box-Button-link"><h6><a class="tm_element-link" href="' . esc_attr( $url['url'] ) . '" title="' . esc_attr( $url['title'] ) . '" target="' . ( strlen( $url['target'] ) > 0 ? esc_attr( $url['target'] ) : '_self' ) . '">'.$tm_box['static_buttontitle'].'</a></h6></div>' : '' ;
		
					}
		
					
					$return .= themetechmount_column_div('start', $column );
						$return .= '
						<div class="tm-history-box-wrapper">
							<div class="tm-history-box-content" >
							  <div class="tm-history-box-icon-wrapper">
							    '.$tm_bicon.'
							  </div>
							  <div class="tm-history-box-border"></div>
							  <div class="tm-history-box-details">
								'.$static_boxtitle.'
								'.$staticbox_desc.'
								'.$static_buttontitle.'
							  </div>
							</div>
						</div>
						';
					$return .= themetechmount_column_div('end', $column );
				} // end foreach
				$return .= '</div>';
				
			} // end if
			
		$return .= themetechmount_box_wrapper( 'end', 'static', get_defined_vars() );
		
		/* Restore original Post Data */
		wp_reset_postdata();
	
} else {
		$return .= '<!-- Visual Composer plugin not installed. Please install it to make this shortcode work. -->';
	}

	return $return;	
	
}
}
add_shortcode( 'tm-static-contentbox', 'themetechmount_sc_static_contentbox' );