1

Ok I am trying to modify some code in a WP Plugin. The plugin declares a file for this:

// overwrite hooks 
$plugin_dir = trailingslashit(dirname(dirname(__FILE__)));
if(file_exists($plugin_dir . "auto_overwrite.php")){
include_once($plugin_dir . "auto_overwrite.php");
}

So I created a file in the above directory called auto_overwrite.php and included the function I wanted to change.

The problem I am having is that I still get the error:

Fatal error: Cannot redeclare listing_tabs() (previously declared in....

I thought the idea of include_once was that is would not include functions that are already defined.

The other function is in a file named meta_boxes.php and it too is called via

include_once("meta_boxes.php");

I am relatively new to PHP so maybe I'm missing something, any help is greatly appreciated. Thanks!

EDIT: From answers below I see that I cant just call out the function as include_once only limits that specific file from being loaded more than once. Basically I am trying to modify a function specified downstream from this file. Is it possible to do this?

4

1 回答 1

0

你可以检查一个函数是否已经定义,如果没有像这样采取相应的行动......

 if (!function_exists('listing_tabs')){
    // include file with function
 }
于 2016-12-28T18:05:07.867 回答