How to Disable Right Click and Text Selection in WordPress

In this WordPress tutorial, you will learn how to disable right and text selection in WordPress.

How to Disable Right Click and Text Selection in WordPress

Get The Code Here

function disable_right_click_text_selection() {
echo '<script>
// Disable right-click
document.addEventListener("contextmenu", function(e) {
e.preventDefault();
});

// Disable text selection
document.addEventListener("selectstart", function(e) {
e.preventDefault();
});
</script>';
}
add_action('wp_footer', 'disable_right_click_text_selection');

Leave a Reply

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