I am newbie in php, but I need to modify some string in order to add a link with rel intro a visual composer shortcode, an animated icon. The problem is that I have this variable, by default where i should add two variables only if insered.
Here is the originary code:
$svg_icon = '<div class="svg-icon-holder" data-size="'. $icon_size . '" data-animation-speed="'.$animation_speed_time.'" data-animation="'.$enable_animation.'" data-animation-delay="'.$animation_delay.'" data-color="'.strtolower($color) .'"><span>'. get_template_directory_uri() . '/css/fonts/svg/' . $image .'</span></div>';
The problem is that: I should insert a <a href="'. $icon_link . '" rel="'. $icon_link_rel .'"> before the tag <div> into the code and a </a> after the closing div BUT this only if variable &icon_link is set, if not, the <a> tag should not appear as I do not need to have a link to all icons.
Hope I have explained myself well, if not let me know!
Regards, Alin.
Do an if-statement, if $icon_link is defined and set, then add your <a> tag to your $svg_icon variable using a dot(.):
$svg_icon = '<div class="svg-icon-holder" data-size="'. $icon_size . '" data-animation-speed="'.$animation_speed_time.'" data-animation="'.$enable_animation.'" data-animation-delay="'.$animation_delay.'" data-color="'.strtolower($color) .'"><span>'. get_template_directory_uri() . '/css/fonts/svg/' . $image .'</span></div>';
if($icon_link)
{
$svg_icon = '<a href="'. $icon_link . '" rel="'. $icon_link_rel .'">'.
$svg_icon.'</a>';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With