1

All the working coupon manager plugins in Wordpress are paid. So, I thought of creating a new one. I wanted to create a coupon box like one this site has: http://www.bestbigrockcoupons.com/

So far I've managed to create a Shortcode on Wordpress to generate the coupon box. Here's the code:

function couponbox_func($atts) {
  extract(shortcode_atts(array(
      'coupon' => '',
      'url' => '',
      'expires' => '',
   ), $atts));
if($expires)
{
$expires = "<span class=\"expires\">Expires: " . $expires . "</span><br>";
}
  if($name && $url)
{ 
  return "<div class=\"cbox\">
   " . $expires . "
   <a class=\"myButton\" href=\""
   . $url . "
   \" target=\"_blank\">" . $coupon . "</a>
   </div>";
}
}
add_shortcode( 'couponbox', 'couponbox_func' );

Now my question is that what should I do so that when a user clicks on the box, the coupon ($coupon) gets copied in user's clipboard similar to what happens in the above mentioned site.

Thanks.

  • Best bet is to use Flash as browser support for javascript clipboard actions is very limited. ( http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard.html ) - or use the code from here http://code.tutsplus.com/tutorials/quick-tip-create-a-copy-to-clipboard-button-in-flash--active-3123 – Professor Abronsius Mar 31 '15 at 09:46
  • 2
    possible duplicate of [How do I copy to the clipboard in JavaScript?](http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript) – Alex Mar 31 '15 at 09:48

0 Answers0