Skip to content

Instantly share code, notes, and snippets.

@Hunter-WebDev
Last active August 29, 2019 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hunter-WebDev/d902ad436816c356b9c25e0a2475395a to your computer and use it in GitHub Desktop.
Save Hunter-WebDev/d902ad436816c356b9c25e0a2475395a to your computer and use it in GitHub Desktop.
Used to generate the mail tags into the message body, blog post explaining how to use this gist: https://hunterwebdev.io/blog/quickly-add-all-contact-form-7-tags-when-creating-form/
var $ = jQuery;
var copy = "\n\n";
var i = 0;
$('#wpcf7-mail .mailtag.code.unused').each(function(){
var text = $(this).text();
var key = text.replace(/\[|]/g, '');
copy += key.replace(/\-|_/g, ' ').toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
}) + ": " + text + "\n";
i++;
});
console.log('Lines Typed: ' + i);
$('#wpcf7-mail-body').val($('#wpcf7-mail-body').val() + copy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment