简体   繁体   English

无法在 wordpress 中重新声明 function

[英]Cannot redeclare function in wordpress

I have a following function in one of the files for this plugin "BJ lazy load".我在此插件“BJ 延迟加载”的文件之一中有以下 function。

<?php

function bjll_compat_operamini() {
    if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) ) {
        add_filter( 'bjll/enabled', '__return_false' );
    }
}

add_action( 'bjll/compat', 'bjll_compat_operamini' );

And for some reason, I keep getting this error:由于某种原因,我不断收到此错误:

Fatal error: Cannot redeclare bjll_compat_operamini() (previously declared in /home/brbzdksz/public_html/abeyuto.com/wp-content/plugins/bj-lazy-load/inc/compat/opera-mini.php:4) in /home/brbzdksz/public_html/abeyuto.com/wp-content/plugins/bj-lazy-load/inc/compat/opera-mini.php on line 4致命错误:无法在 /home 中重新声明 bjll_compat_operamini()(之前在 /home/brbzdksz/public_html/abeyuto.com/wp-content/plugins/bj-lazy-load/inc/compat/opera-mini.php:4 中声明) /brbzdksz/public_html/abeyuto.com/wp-content/plugins/bj-lazy-load/inc/compat/opera-mini.php 在第 4 行

What I can't figure out here is how this function is being declared twice on the same line, which is line 4.我在这里想不通的是这个 function 如何在同一行(即第 4 行)上声明两次。

Any ideas would be greatly appreciated.任何想法将不胜感激。 Thank you.谢谢你。

Most likely, this file is being loaded twice -- meaning that the problem is not in this code.最有可能的是,这个文件被加载了两次——这意味着问题不在这个代码中。 If you are using "require" to load the file, you can fix this simply by using "require_once" instead.如果你使用“require”来加载文件,你可以简单地通过使用“require_once”来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM