I am struggling to understand scope and what's preventing my new code from working (assuming it is a scope issue).
The following function is in a file PATH.'/includes/custom-functions.php'
that references a class:
function infusion() {
require_once(PATH.'/classes/infusion.php'); //PATH is defined in WordPress from ~/wp-content/themes/theme/
return new infusion();
}
The class is reliant on PATH.'/api/isdk.php'
and connection credentials from another file within /api/
directory. From within PATH .'/includes/custom-functions.php'
, I have many other functions that call $infusion = infusion();
and work perfectly.
PROBLEM
I have created a new file: PATH.'/includes/report.php'
which I need to access $infusion = infusion();
but can't get to work by either repeating the function infusion()
definition from above; using require_once();
; or using include();
. All 3 of those options simply kill the rest of the code and I can only come to the conclusion - well, I have no conclusion.
Any help would be greatly appreciated.