longnguyenwp

OpCoupon.com

Mar 5th, 2021
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.92 KB | None | 0 0
  1. add_action( 'wp_footer', function() {
  2.     ?>
  3.     <script type="text/javascript">
  4.         jQuery(document).ready(function($) {
  5.             $( 'body' ) .on( 'click', '.coupon-button-type .coupon-button, .coupon-title a.coupon-link, .coupon-link', function ( e ) {
  6.                 e.preventDefault();
  7.  
  8.                 var current_url, coupon_id, aff_url, t;
  9.                 current_url = $( this ).attr( 'href' );
  10.  
  11.                 if ( $( this).hasClass( 'coupon-button' ) ) {
  12.                     coupon_id = $(this).data('coupon-id') || undefined;
  13.                     aff_url = $(this).attr('data-aff-url');
  14.                     current_url = $( this ).attr( 'href' );
  15.                         t = $(this).attr('data-type') || '';
  16.                         if (
  17.                             ( t == 'print' && ST.print_prev_tab != 1 )
  18.                             || ( t == 'code' && ST.code_prev_tab != 1 )
  19.                             || ( t == 'sale' && ST.sale_prev_tab != 1 )
  20.                         ) {
  21.                             window.open( current_url, '_self');
  22.                         } else {
  23.                             if ( ST.coupon_click_action === 'next' ) {
  24.                                 window.open(  aff_url, '_blank');
  25.                                 window.open( current_url, '_self');  
  26.                             } else {
  27.                                 window.open( current_url, '_blank');
  28.                                 window.open( aff_url, '_self');
  29.                             }
  30.                         }
  31.  
  32.                     return false;
  33.  
  34.                 } else if ( $(e.target).hasClass( 'coupon-link' ) ) {
  35.                     current_url = $( this ).attr( 'href' );
  36.                     window.open( current_url, '_self' );
  37.                 } else {
  38.                     coupon_id = $(this).data('coupon-id') || undefined;
  39.  
  40.                     if ( typeof coupon_id == "undefined") {
  41.                         return false;
  42.                     }
  43.  
  44.                     // Copy code to clipboard
  45.                     var code = $(this).attr('data-code') || '';
  46.                     if (code && code != '') {
  47.                         copyText(code);
  48.                     }
  49.  
  50.                     t = $(this).attr('data-type') || '';
  51.  
  52.                     // Track print coupon clicked
  53.                     if ( t === 'print' ) {
  54.                         track_coupon( coupon_id );
  55.                     }
  56.  
  57.                     if (
  58.                         ( t == 'print' && ST.print_prev_tab != 1 )
  59.                         || ( t == 'code' && ST.code_prev_tab != 1 )
  60.                         || ( t == 'sale' && ST.sale_prev_tab != 1 )
  61.                     ) {
  62.                         //aff_url = $(this).attr('data-aff-url');
  63.                         //window.open( current_url, '_self' );
  64.                         openCouponModal( coupon_id );
  65.                     } else {
  66.                         aff_url = $(this).attr('data-aff-url');
  67.                         current_url = $(this).attr('href');
  68.  
  69.                         if ( ST.coupon_click_action === 'next' ) {
  70.                             window.open(  aff_url, '_blank');
  71.                             window.open( current_url, '_self');
  72.                         } else {
  73.                             window.open( current_url, '_blank');
  74.                             window.open( aff_url, '_self');
  75.                         }
  76.  
  77.                         return false;
  78.                     }
  79.                 }
  80.             } );
  81.         });
  82.     </script>
  83.     <?php
  84. } );
Advertisement
Add Comment
Please, Sign In to add comment