From 3291510058be2349e896e0ba78d8b5852b80b435 Mon Sep 17 00:00:00 2001 From: Thor Brink Date: Mon, 25 Sep 2023 05:13:03 +0000 Subject: [PATCH] fix: catch error from ensureWPApiSettings error thrown in administration interface due to not being (and should not be) available. --- source/js/modularity.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/js/modularity.js b/source/js/modularity.js index acc1793e0..f04a5b3fb 100644 --- a/source/js/modularity.js +++ b/source/js/modularity.js @@ -97,12 +97,16 @@ if (!parent.Modularity) { } (function () { - ensureWPApiSettings(); - - const { root, nonce } = window.wpApiSettings; - const fetch = window.fetch.bind(window); - const endpoints = ModulesRestAPIEndpoints(root); - const restAPI = new ModulesRestAPI(fetch, endpoints, nonce); - - new ModuleRefresher(restAPI).refreshModules(); + try { + ensureWPApiSettings(); + + const { root, nonce } = window.wpApiSettings; + const fetch = window.fetch.bind(window); + const endpoints = ModulesRestAPIEndpoints(root); + const restAPI = new ModulesRestAPI(fetch, endpoints, nonce); + + new ModuleRefresher(restAPI).refreshModules(); + } catch (error) { + console.warn(error); + } })(); \ No newline at end of file