Disable right click and prevent copy paste with 2 methods on WordPress

Code for function.php file

if ( !is_user_logged_in() ) {
 function disable_right_click_idc() {
 ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
document.addEventListener("contextmenu", function(e) {
 e.preventDefault();
}, false);
$("body").css("-webkit-user-select", "none");
$("body").css("-moz-user-select", "none");
$("body").css("-ms-user-select", "none");
$("body").css("user-select", "none");
</script>
<?php
}
add_action('wp_footer', 'disable_right_click_idc');
}

Optional: Extra CSS layer for Appearance>Customize>Additional CSS

* {
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none; /* Safari */
  -khtml-user-select: none; /* Konqueror HTML */
  -moz-user-select: none; /* Old versions of Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
   user-select: none; /* Non-prefixed version, currently supported by Chrome, Opera and Firefox */
}