Skip to content

Instantly share code, notes, and snippets.

@jmarreros
Last active July 20, 2021 21:10
Show Gist options
  • Save jmarreros/2b02de8a18e52d941119fadc3c2fc0d5 to your computer and use it in GitHub Desktop.
Save jmarreros/2b02de8a18e52d941119fadc3c2fc0d5 to your computer and use it in GitHub Desktop.
Evita el copiar pegar, la selección de texto y el menú contextual en una página específica de WordPress
<?php // No copiar este línea
add_action('wp_footer', 'dcms_avoid_copy_paste');
function dcms_avoid_copy_paste() {
if ( is_page('politica-privacidad') ):
?>
<script>
(function( $ ) {
// Evitar copiar pegar y menu contextual
$('body').bind('copy contextmenu',function(e) {
e.preventDefault(); return false;
});
// Evitar selección
$(document).ready(function(){
$("body").css("-webkit-user-select","none");
$("body").css("-moz-user-select","none");
$("body").css("-ms-user-select","none");
$("body").css("-o-user-select","none");
$("body").css("user-select","none");
});
})( jQuery );
</script>
<?php
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment