# phastpress/1.82/classes/WordPress.php

PhastPress, version 1.82. 66 lines.

- Page: https://pluginprobe.com/plugins/phastpress/1.82/code/classes/WordPress.php
- Raw: https://pluginprobe.com/plugins/phastpress/1.82/raw/classes/WordPress.php
- Modified: 2020-04-02T16:30:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/phastpress/1.82/code/classes/WordPress.php#L10-L20`.

```php
<?php
namespace Kibo\PhastPlugins\PhastPress;

use Exception;
use Requests;
use RuntimeException;

class WordPress {
    public static function loadConfig() {
        if (defined('ABSPATH')) {
            return;
        }
        $complete = false;
        $hook = function () use (&$complete) {
            if (!$complete && defined('WP_CONTENT_DIR')) {
                throw new WordPressLoadedException();
            }
        };
        $GLOBALS['wp_filter']['all'][0][] = [
            'function' => $hook,
            'accepted_args' => 0,
        ];
        try {
            require self::findWPLoad();
        } catch (WordPressLoadedException $e) {
            return;
        } finally {
            $complete = true;
        }
        throw new RuntimeException('WordPress loaded without triggering any hooks');
    }

    private static function findWPLoad() {
        $startDir = dirname($_SERVER['SCRIPT_FILENAME']);
        if (!$startDir) {
            throw new RuntimeException('Could not get directory from SCRIPT_FILENAME');
        }
        $dir = $startDir;
        while (true) {
            $path = $dir . '/wp-load.php';
            if (file_exists($path)) {
                return $path;
            }
            $parent = dirname($dir);
            if ($parent == $dir) {
                break;
            }
            $dir = $parent;
        }
        throw new RuntimeException(
            "Could not find wp-load.php in $startDir or any of its parent directories"
        );
    }

    public static function loadRequests() {
        if (!class_exists(Requests::class)) {
            require ABSPATH . WPINC . '/class-requests.php';
            Requests::register_autoloader();
            Requests::set_certificate_path(ABSPATH . WPINC . '/certificates/ca-bundle.crt');
        }
    }
}

class WordPressLoadedException extends Exception {
}

```
