Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Retrieve WordPress root directory path? #9950
    blankomry-yadan
    Participant

    Note: This answer is really old and things may have changed in WordPress land since.

    I am guessing that you need to detect the WordPress root from your plugin or theme.
    I use the following code in FireStats to detect the root WordPress directory where FireStats is installed a a WordPress plugin.

    function fs_get_wp_config_path()
    {
        $base = dirname(__FILE__);
        $path = false;
    
        if (@file_exists(dirname(dirname($base))."/wp-config.php"))
        {
            $path = dirname(dirname($base))."/wp-config.php";
        }
        else
        if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php"))
        {
            $path = dirname(dirname(dirname($base)))."/wp-config.php";
        }
        else
            $path = false;
    
        if ($path != false)
        {
            $path = str_replace("\\", "/", $path);
        }
        return $path;
    }
    
Viewing 1 post (of 1 total)