From 835c357b8a978dd43a4a195d9df4ed582b7a6130 Mon Sep 17 00:00:00 2001 From: Carl Alexander Date: Tue, 14 Dec 2021 12:38:27 -0500 Subject: [PATCH] fix: make sure `WP_Rewrite` is initialized --- src/Configuration/WordPressConfiguration.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Configuration/WordPressConfiguration.php b/src/Configuration/WordPressConfiguration.php index c92980d..e0238c5 100644 --- a/src/Configuration/WordPressConfiguration.php +++ b/src/Configuration/WordPressConfiguration.php @@ -87,6 +87,13 @@ public function modify(Container $container) ]; }); $container['rest_url'] = $container->service(function () { + global $wp_rewrite; + + if (!$wp_rewrite instanceof \WP_Rewrite) { + $wp_rewrite = new \WP_Rewrite(); + $wp_rewrite->init(); + } + return get_rest_url(); }); $container['site_icon'] = $container->service(function () {