How to correct an error using require_once() on a live wordpress site?

26 views Asked by At

I've developed an ACF Pro plugin for Wordpress which works fine on my local machine.

When I install the plugin on a live machine however, I get the following error: [13-May-2023 10:08:14 UTC] PHP Warning: require_once(../../DataModel/ChildBlockModels/ChildBlockDataModel.php): failed to open stream: No such file or directory in /home/wpsitebo/stephenbugden.com/wp-content/plugins/netmonics-acf-cards-render-template/php_functions/BusinessModel/ChildBlockModels/ChildBlockBusinessModel.php on line 3 So it's complaining that a required file 'ChildBlockDataModel.php' doesn't exist.

ChildBlockBusinessModel.php requires the file as follows:

require_once('../../DataModel/ChildBlockModels/ChildBlockDataModel.php');

The file is definitely there.

I also tried: require_once(dir . '/../../DataModel/ChildBlockModels/ChildBlockDataModel.php'); But that gives a similar error.

So does anyone please have an suggestions as to how I can use relative addressing with require_once?

Best Regards,

Steve

1

There are 1 answers

0
Steve On

To answer my own question, eventually I discovered that I'd referenced a file like this: require_once('NumerationModel.php'); but the file was actually 'NumerationModel.PHP'

I changed it and it now works fine.

Not sure why I got an error on another file missing i.e. 'ChildBlockDataModel.php'

Steve