phpwordpresspluginslazy-loadingredeclare

Cannot redeclare function in wordpress


I have a following function in one of the files for this plugin "BJ lazy load".

<?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

What I can't figure out here is how this function is being declared twice on the same line, which is line 4.

Any ideas would be greatly appreciated. Thank you.


Solution

  • 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.