I’ve got some functions in my file that require taxonomy.php to execute. I’m attempting to include the file like so…(this is called from functions.php, which is located in wp_content/themes/mytheme/
include($_SERVER['DOCUMENT_ROOT'] .'/wp-admin/includes/taxonomy.php');
However, depending on the particular server setup, its hit or miss (mostly hit) whether the include will be found. In the case its not found, I get this error…
Warning: include(/home/user/domainname.com/wp-admin/includes/taxonomy.php) [function.include]: failed to open stream: No such file or directory in /home/user/domainname.com/testing123/wp-content/themes/mytheme/functions.php on line 10
UPDATE: Assuming I’m already doing about as much as I can by using DOCUMENT_ROOT, is there a means of avoiding the error that occurs when the file is not found? And I will be checking for function_exists in any functions that require taxonomy.php so as to suppress errors…
Well, the only way to bulletproof this is to actually configure it on each server you deploy it on. If you can’t assume
document_rootis a reliable factor, I can’t imagine any other variable that could give you a better result.You could start searching for
taxonomy.phpbut that is expensive, and horribly prone to failure or picking the wrong file (what happens if my neighbor has wordpress installed in/home/user/domainname2.com?