Advertisement
Guest User

copy and paste code

a guest
Aug 12th, 2013
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. function add_copyright_text() {
  2.     if (is_single()) { ?>
  3.  
  4. <script type='text/javascript'>
  5. function addLink() {
  6.     if (
  7. window.getSelection().containsNode(
  8. document.getElementsByClassName('entry-content')[0], true)) {
  9.     var body_element = document.getElementsByTagName('body')[0];
  10.     var selection;
  11.     selection = window.getSelection();
  12.     var oldselection = selection
  13.     var pagelink = "<br /><br /> Read more: <?php the_title(); ?> <a href='<?php echo get_permalink(get_the_ID()); ?>'><?php echo get_permalink(get_the_ID()); ?></a>"; //Change this if you like
  14.     var copy_text = selection + pagelink;
  15.     var new_div = document.createElement('div');
  16.     new_div.style.left='-99999px';
  17.     new_div.style.position='absolute';
  18.  
  19.     body_element.appendChild(new_div );
  20.     new_div.innerHTML = copy_text ;
  21.     selection.selectAllChildren(new_div );
  22.     window.setTimeout(function() {
  23.         body_element.removeChild(new_div );
  24.     },0);
  25. }
  26. }
  27.  
  28.  
  29. document.oncopy = addLink;
  30. </script>
  31.  
  32. <?php
  33. }
  34. }
  35.  
  36. add_action( 'wp_head', 'add_copyright_text');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement