Skip to content

Instantly share code, notes, and snippets.

@sudipto-me
Created May 24, 2019 09:18
Show Gist options
  • Save sudipto-me/9d7131519b03b141c2ce99dc8e54da09 to your computer and use it in GitHub Desktop.
Save sudipto-me/9d7131519b03b141c2ce99dc8e54da09 to your computer and use it in GitHub Desktop.
Extract some features for the vc map. This are mainly used for the elements: "vc_link","font-size","google_fonts".
/*
* VC Map Extract String
*/
if ( ! function_exists( 'fts_vc_map_extract_string' ) )
{
function fts_vc_map_extract_string( $input )
{
$font_elements = explode('|',$input);
$final_array = array();
foreach ($font_elements as $font_element) {
if( ! empty($font_element)){
$new_array = explode(':',$font_element);
$final_array[$new_array[0]] = urldecode($new_array[1]);
}
}
return $final_array;
}
}
/*
* VC Map Google Font Style Array
*/
if ( ! function_exists( 'fts_vc_map_google_font_style' ) )
{
function fts_vc_map_google_font_style($google_final_array)
{
//var_dump($google_final_array);
$font_family = explode(':',$google_final_array['font_family']);
$font_style = explode(':',$google_final_array['font_style']);
$font_style_final = explode(' ',$font_style[0]);
$font_style_final_check = ($font_style_final[1] == 'regular') ? 'normal' : $font_style_final[1];
return $font = 'font-family:'.$font_family[0].';font-weight:'.$font_style_final[0].';font-style:'.$font_style_final_check;
}
}
/*
* VC Map Pixel Checking
*/
if ( ! function_exists( 'fts_vc_map_px_checking' ) )
{
function fts_vc_map_px_checking($str)
{
$pos = strrpos($str, "px");
if ($pos === false) {
return $str.'px';
}
else {
return $str;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment