At present, I am disabling Right Click through the use of the following code:
<?php
// Disable Right Click
function disable_right_click() {
?>
<script>
jQuery(document).ready(function(){
jQuery(document).bind("contextmenu",function(e){
return false;
});
});
</script>
<?php
}
add_action('wp_head', 'disable_right_click');
add_action('admin_head', 'disable_right_click');
?>
The only problem is, the right click feature works for a second or 2 as the page is loading. I assume this is because the script loads quite late.
Is there any way to get the above code loaded instantly? Possible being the first script to load?
The code does not seem to work with earlier Hooks, such as init
, pre_get_posts
and get_header
. Nor does the use of an integer work. For example:
add_action('wp_head', 'disable_right_click', 1);
Any ideas on how I can get the above script to be the first script loaded?