Advertisement
jaideep06

Sponsored links

Jul 28th, 2021
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.52 KB | None | 0 0
  1. add_action( 'wp_head', function () { ?>
  2. <script>
  3.     /* write your JavaScript code here */
  4.     //<![CDATA
  5.     jQuery(document).ready(function($) {
  6.         $('a').each(function() {
  7.             var a = new RegExp('/' + window.location.host + '/');
  8.             if (!a.test(this.href)) {
  9.                 $(this).attr("rel","sponsored nofollow noopener noreferrer");
  10.                 //$(this).click(function(event) {
  11.                     //event.preventDefault();
  12.                     //event.stopPropagation();
  13.                     //window.open(this.href, '_blank');
  14.                 //});
  15.             }
  16.         });
  17.     });
  18.     //]]>
  19. </script>
  20. <?php } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement