Understanding ABSPATH at BionicWP
At BionicWP, the WordPress Core files are symbolically linked to another location on the platform. In other words, they are not in the site root as in a standard WordPress install. Because of this, using ABSPATH to locate files in the site can sometimes result in errors.
Understanding ABSPATH
<?php
var_dump(ABSPATH);
Returns:
string(19) "/srv/htdocs/__wp__/"
ABSPATH vs. WP_CONTENT_DIR
ABSPATH can be used when pointing to core files, but it will not function correctly if used to locate files or folders within wp-content.
For example, the following on BionicWP:
$target_path = ABSPATH . 'wp-content/plugins/order-tracking/order-sheets/';Should be updated to:
$target_path = WP_CONTENT_DIR . '/plugins/order-tracking/order-sheets/';With WP_CONTENT_DIR, files/folders in the site root can be successfully accessed. Note that ABSPATH has a trailing slash, whereas WP_CONTENT_DIR does not.
Create Your Own Constant
If you need to access the site root in multiple parts of your code and want a more flexible approach, we recommend defining a custom PHP constant:
define('BIONICWP_SITE_ROOT', str_replace('wp-content', '', WP_CONTENT_DIR));This defines BIONICWP_SITE_ROOT as /srv/htdocs/ and can be used like this:
$target_path = BIONICWP_SITE_ROOT . 'wp-content/plugins/order-tracking/order-sheets/';This constant could be placed in a plugin or a theme. It is not recommended to use this constant in wp-config.php because some hosting platforms often do not migrate wp-config.php or allow it to be modified.
Paths in WP-Admin
While not preferable, if a plugin ever requires you to set an option for your site root via wp-admin, you should use the following path: /srv/htdocs
If you have questions about this, please contact support.
