Here I have the exact same code in 2 places. If the code is run from example.php (in the root of my WordPress site), it works fine.
[works!])But, if I put that same code into a plugin PHP file and call it from example.php it fails (just nothing is written to the screen). Why?
​
[this fails])Does this have anything to do with the WordPress directory structure? Why would the same code run fine in a file in the WordPress root folder, but fail when called from a WordPress plugin?
Occasionally I will get the words “Curl Error:” onscreen when trying to run the code from the plugin. No number for the Curl error, no explanation….
​
[useless curl error ])***UPDATE —-*** So I just got desperate and started changing everything…. I tried every combination of changes that I could think of and it still didn’t work.
Next I started trying things I had never heard of – and I found the problem.
It seems that it isn’t enough for the 2nd file (the one whose function is being called) to “require\_once” the files that it needs. The calling file must also “require\_once” those same files.
​
Now this doesn’t make sense to me on multiple levels.
* why don’t the files included in the plugin’s PHP file bubble up to the caller?
* this seems wildly inefficient. Are we supposed to find ALL require\_once statements in any file that we call a function in, and in every file that it calls – recursively?
​
[ad_2]