juandahveed
9/28/2017 - 1:15 PM

Non MO Phone Number Shortcode

Non MO Phone Number Shortcode

//phone number shortcode
function phoneShortCode($atts){
		
	$atts = shortcode_atts( array(
		'ctc'=> false,
		'phone_number'=>'1 (424) 320-6225',
		'class'=> ''
	), $atts );
	
	$output = '';
	
	if ( $atts['ctc'] == false ) {
		$output .= '<span class="' . $atts["class"] . '">' . $atts["phone_number"] . '</span>';
		
	} else if ( $atts['ctc'] == true ) {
		$output .= '<a href="tel:+' . $atts["phone_number"] . '"><span class="' . $atts["class"] . '">' . $atts["phone_number"] . '</span></a>';
	} else {
		$output .= 'Something went wrong';
	}
	
	return $output;
}

add_shortcode('phone_number' , 'phoneShortCode');