I have a command line script for maintaining a wordpress plugin and have to determine the wordpress base path to be able to load the wordpress core.
I could just assume the script is several levels under the base path. But if I want to reuse the code and I have another similar script that needs to determine the wordpress base path I would have to adjust the level depth. This is error prone.
ABSPATH can't be used since it is not defined in the command line script. In fact its value is necessary to be able to load the wordpress core and which will define it.
So how do I determine the wordpress base path when the wordpress environment is not loaded yet?
Similar question: What is the best way to get directory path for wp-config.php?