Hi,
Thank you for sharing error message of your debug file and the solution of the issue.
We have looped into the directory for finding the wp-load.php file, as some of the clients had renamed the default directory name using one of the plugins. So the current code was meant to find the wp-load.php file and include it, so we can use the WordPress functions.
The solution which you shared with me was the original code for including the wp-load.php file in our plugin. But for above issue which I have explained, we have changed the code.
Can you please let me know where is the “wp-load.php” file present in your directory as you have changed it using Roots’ Bedrock for WordPress?
So, yes I will look for another solution which will work on all scenario.
[ Signature deleted ]
Thread Starter
lvl99
(@lvl99)
Hiya Chetna,
Here’s the full code, in which I have modified only the first line:
if ( ! file_exists( $wp_load = untrailingslashit( ABSPATH ) . "/wp-load.php" ) ) {
$wp_load = false;
$dir = __FILE__;
while( '/' != ( $dir = dirname( $dir ) ) ) {
if( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
break;
}
}
}
require_once $wp_load;
It should check for the ABSPATH location first, and if it returns false, it then checks in other folders.
With Roots’ Bedrock, they put WP files in a /path/to/website/web/wp/
folder (all other files like uploads, themes and plugins are in the /path/to/website/web/app/
folder), however I’ve modified mine to have WP files in the /path/to/website/web/cms/
folder. Either way, for Root’s Bedrock the ABSPATH points to the folder which contains all the WP CMS files.
For my server, the wp-load.php file is within the WP CMS folder located at /home/exampleuser/example.com/web/cms/wp-load.php
. This means that when your original cron script runs, it can’t find the wp-load.php
file because it’s going up from a directory that is separate to the WP CMS files, i.e. /home/exampleuser/example.com/web/app/plugins/woocommerce-abandoned-cart/
. The cron script produces errors with a path that specifies /home/wp-load.php
.
Hi,
Thank you for sharing such a valuable information and sharing the solution with us.
Yes, you are right. The cron script could not find out “wp-load.php” file as the path has been changed for WordPress core files.
I will look into it and include this solution which can work on all setup in our plugin.
Thank you for your co-operation.
Regards,
Chetna Bhutka