最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - What is the earliest Hook a Script can use?

programmeradmin4浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论