PluginProbe
PhastPress / 1.78
PhastPress v1.78
3.12 3.11 1.75 1.76 1.77 1.78 1.79 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.90 1.91 1.92 1.93 1.94 1.95 1.96 1.97 All 119 releases
← All changes | classes/WordPress.php +13 -37 3.121.78 View file →
@@ -9,45 +9,26 @@
9 9 public static function loadConfig() {
10 10 if (defined('ABSPATH')) {
11 11 return;
12 12 }
13 -
14 13 $complete = false;
15 -
16 - // If set_error_handler is used in wp-config.php this will be a fallback
14 + $hook = function () use (&$complete) {
15 + if (!$complete && defined('WP_CONTENT_DIR')) {
16 + throw new WordPressLoadedException();
17 + }
18 + };
17 19 $GLOBALS['wp_filter']['all'][0][] = [
18 - 'function' => function () use (&$complete) {
19 - if (!$complete && defined('WP_CONTENT_DIR')) {
20 - throw new WordPressLoadedException();
21 - }
22 - },
20 + 'function' => $hook,
23 21 'accepted_args' => 0,
24 22 ];
25 -
26 - // This should trigger as soon as wp-settings.php is loaded
27 - set_error_handler(function ($errno, $errstr, $errfile) use ($complete) {
28 - if (!$complete && basename($errfile) === 'wp-settings.php') {
29 - throw new WordPressLoadedException();
30 - }
31 - });
32 -
33 - // Cause an error to be raised when wp-settings.php is loaded
34 - define('WPINC', 'wp-includes');
35 -
36 23 try {
37 - $wpLoadScript = self::findWPLoad();
38 - chdir(dirname($wpLoadScript));
39 - require $wpLoadScript;
40 - throw new RuntimeException('WordPress loaded without triggering any hooks');
24 + require self::findWPLoad();
41 25 } catch (WordPressLoadedException $e) {
26 + return;
42 27 } finally {
43 28 $complete = true;
44 - set_error_handler(null);
45 29 }
46 -
47 - if (!defined('WP_CONTENT_DIR')) {
48 - define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
49 - }
30 + throw new RuntimeException('WordPress loaded without triggering any hooks');
50 31 }
51 32
52 33 private static function findWPLoad() {
53 34 $startDir = dirname($_SERVER['SCRIPT_FILENAME']);
@@ -59,12 +40,8 @@
59 40 $path = $dir . '/wp-load.php';
60 41 if (file_exists($path)) {
61 42 return $path;
62 43 }
63 - $wpPath = $dir . '/wp/wp-load.php';
64 - if (file_exists($wpPath)) {
65 - return $wpPath;
66 - }
67 44 $parent = dirname($dir);
68 45 if ($parent == $dir) {
69 46 break;
70 47 }
@@ -75,14 +52,13 @@
75 52 );
76 53 }
77 54
78 55 public static function loadRequests() {
79 - if (class_exists(\WpOrg\Requests\Requests::class)) {
80 - return;
56 + if (!class_exists(Requests::class)) {
57 + require ABSPATH . WPINC . '/class-requests.php';
58 + Requests::register_autoloader();
59 + Requests::set_certificate_path(ABSPATH . WPINC . '/certificates/ca-bundle.crt');
81 60 }
82 - require ABSPATH . WPINC . '/Requests/src/Autoload.php';
83 - \WpOrg\Requests\Autoload::register();
84 - \WpOrg\Requests\Requests::set_certificate_path(ABSPATH . WPINC . '/certificates/ca-bundle.crt');
85 61 }
86 62 }
87 63
88 64 class WordPressLoadedException extends Exception {