I have this shortcode:
function fm_requestebook ($atts) {
$atts = shortcode_atts(array(
'cf7' => null,
'filename' => null,
'event' => null,
'testo' => "Scarica eBook"
), $atts);
$contact_form = do_shortcode("[contact-form-7 id=".$atts['cf7']."]");
$hf = '<input type="hidden" name="_FM_ebook" value="' . $atts["filename"]. '" /></form>';
$contact_form = str_replace("</form>", $hf, $contact_form);
$return='<a onclick="ga(\'send\',\'event\', \'Download\', \'ebook\', \''.$atts["event"].'\');" class="fancybox" href="#ebook" target="_blank" rel="nofollow"><span class="red-button">'.$atts["testo"].'</span></a><div class="fancybox-hidden" style="display: none;"><div id="ebook" class="hentry">'.$contact_form.'</div></div>';
return do_shortcode($return);
}
add_shortcode ("request-ebook","fm_requestebook");
The problem is that if I put more than one instance of the shortcode on the same page, all the subsequent codes will have the same "_FM_ebook" value....
Aucun commentaire:
Enregistrer un commentaire