From 7bf80ac0224e0463c2ec992084e70470967491bf Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Fri, 22 Sep 2023 17:50:28 +0530 Subject: [PATCH 1/5] Provide more flexibility when loading runtime JS --- includes/Runtime.php | 6 ++++++ includes/runtime.js | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 includes/runtime.js diff --git a/includes/Runtime.php b/includes/Runtime.php index b986362..beda7b8 100644 --- a/includes/Runtime.php +++ b/includes/Runtime.php @@ -66,6 +66,12 @@ public function prepareRuntime() { * Load Runtime into the page. */ public function register_runtime() { + \wp_register_script( + 'wp-runtime-script', + $this->container->plugin()->url . 'vendor/newfold-labs/wp-module-runtime/includes/runtime.js', + array( 'wp-url' ), + '1.0.0' + ); \wp_add_inline_script( $this->container->plugin()->id . '-script', 'window.NewfoldRuntime =' . wp_json_encode( $this->prepareRuntime( $this->container ) ) . ';', diff --git a/includes/runtime.js b/includes/runtime.js new file mode 100644 index 0000000..3856f5d --- /dev/null +++ b/includes/runtime.js @@ -0,0 +1,5 @@ +if (typeof window.NewfoldRuntime !== "undefined") { + console.log("Loaded NewFold Runtime"); + } else { + console.log("Error Loading NewFold Runtime"); + } \ No newline at end of file From ff362a594b8791a5e2f5729017a370a88e81719c Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Fri, 22 Sep 2023 17:54:49 +0530 Subject: [PATCH 2/5] nfd-runtime chnages --- includes/Runtime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Runtime.php b/includes/Runtime.php index beda7b8..c173c97 100644 --- a/includes/Runtime.php +++ b/includes/Runtime.php @@ -67,7 +67,7 @@ public function prepareRuntime() { */ public function register_runtime() { \wp_register_script( - 'wp-runtime-script', + 'nfd-runtime', $this->container->plugin()->url . 'vendor/newfold-labs/wp-module-runtime/includes/runtime.js', array( 'wp-url' ), '1.0.0' From 5eebcd94e9e4063be3a62d6e42d0ff0a2cc9b3d7 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Tue, 3 Oct 2023 13:44:26 +0530 Subject: [PATCH 3/5] updated with requested chnages --- includes/Runtime.php | 6 +++--- includes/runtime.js | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 includes/runtime.js diff --git a/includes/Runtime.php b/includes/Runtime.php index c173c97..0433199 100644 --- a/includes/Runtime.php +++ b/includes/Runtime.php @@ -68,9 +68,9 @@ public function prepareRuntime() { public function register_runtime() { \wp_register_script( 'nfd-runtime', - $this->container->plugin()->url . 'vendor/newfold-labs/wp-module-runtime/includes/runtime.js', - array( 'wp-url' ), - '1.0.0' + null, + null, + $wp_version ); \wp_add_inline_script( $this->container->plugin()->id . '-script', diff --git a/includes/runtime.js b/includes/runtime.js deleted file mode 100644 index 3856f5d..0000000 --- a/includes/runtime.js +++ /dev/null @@ -1,5 +0,0 @@ -if (typeof window.NewfoldRuntime !== "undefined") { - console.log("Loaded NewFold Runtime"); - } else { - console.log("Error Loading NewFold Runtime"); - } \ No newline at end of file From 781ba7caed75c4660cdfaa2042557204a2e68593 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 3 Oct 2023 12:23:17 -0400 Subject: [PATCH 4/5] Update Runtime.php Update handle for the inline script too. We want the inline to load anytime a script denotes a dependency on the runtime script. --- includes/Runtime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Runtime.php b/includes/Runtime.php index 0433199..6b7eef7 100644 --- a/includes/Runtime.php +++ b/includes/Runtime.php @@ -73,7 +73,7 @@ public function register_runtime() { $wp_version ); \wp_add_inline_script( - $this->container->plugin()->id . '-script', + 'newfold_runtime', 'window.NewfoldRuntime =' . wp_json_encode( $this->prepareRuntime( $this->container ) ) . ';', 'before' ); From e67ed9d734601c93c9c8c466d6a24b9af89c0bd7 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 3 Oct 2023 15:55:20 -0400 Subject: [PATCH 5/5] fix mismatch script handle --- includes/Runtime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Runtime.php b/includes/Runtime.php index 6b7eef7..6312274 100644 --- a/includes/Runtime.php +++ b/includes/Runtime.php @@ -73,7 +73,7 @@ public function register_runtime() { $wp_version ); \wp_add_inline_script( - 'newfold_runtime', + 'nfd-runtime', 'window.NewfoldRuntime =' . wp_json_encode( $this->prepareRuntime( $this->container ) ) . ';', 'before' );