Created
February 4, 2021 08:10
-
-
Save codename065/0043470a64e5b58a931e329fc268356d to your computer and use it in GitHub Desktop.
How to Disable Text Selection, Copy/Paste and Context Menu on right mouse button click in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function your_function() { | |
?> | |
<script> | |
jQuery(document).ready(function(){ | |
function disableselect(e) { | |
return false; | |
}; | |
function reEnable() { | |
return true; | |
}; | |
document.onselectstart = new Function ("return false") | |
if (window.sidebar) { | |
document.onmousedown = disableselect | |
document.onclick = reEnable | |
}; | |
jQuery(document).bind("contextmenu",function(e){ | |
return false; | |
}); | |
jQuery(document).bind("copy",function(e){ | |
return false; | |
}); | |
jQuery(document).bind("paste",function(e){ | |
return false; | |
}); | |
jQuery(document).bind("select",function(e){ | |
return false; | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action('wp_footer', 'your_function'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment