블로그 글 복사시 출처 자동표시

§

javascript
<script language=JavaScript>
<!–
function copy_play()
{
if (window.event)
{
window.event.returnValue = true;
window.setTimeout(‘capy_plus()’, 25);
}
}
function capy_plus()
{
if (window.clipboardData)
{
var txt = window.clipboardData.getData(‘Text’);

var retUrl = document.URL;
txt = txt +’nn출처 :’+retUrl;
var result = window.clipboardData.setData(‘Text’, txt);
}
}
//–>
</script>

html

<
<div id=’contents_area’ onCopy=’copy_play();’>

워드프레스의 경우:
function add_copyright_text() {
	if (is_single()) { ?>

<script type='text/javascript'>
function addLink() {
	if (
window.getSelection().containsNode(
document.getElementsByClassName('entry-content')[0], true)) {
    var body_element = document.getElementsByTagName('body')[0];
    var selection;
    selection = window.getSelection();
	var oldselection = selection
    var pagelink = "<br /><br /> Read more at WPBeginner: <?php the_title(); ?> <a href='<?php echo wp_get_shortlink(get_the_ID()); ?>'><?php echo wp_get_shortlink(get_the_ID()); ?></a>"; //Change this if you like
    var copy_text = selection + pagelink;
    var new_div = document.createElement('div');
	new_div.style.left='-99999px';
	new_div.style.position='absolute';

    body_element.appendChild(new_div );
    new_div.innerHTML = copy_text ;
    selection.selectAllChildren(new_div );
    window.setTimeout(function() {
        body_element.removeChild(new_div );
    },0);
}
}

document.oncopy = addLink;
</script>

<?php
}
}

add_action( 'wp_head', 'add_copyright_text');

from:

http://www.wpbeginner.com/wp-tutorials/how-to-add-a-read-more-link-to-copied-text-in-wordpress/

hackya 는

Attorney, front-end developer, digital media artist, WordPress enthusiast, & a father of 4 wonderful children.

카테고리: ,

Ω

Leave a Reply

Your email address will not be published. Required fields are marked *