From eb3d0877403191e95f683b10f885d85e1cb231de Mon Sep 17 00:00:00 2001 From: aidamarfuaty Date: Fri, 10 Nov 2023 13:57:51 +0100 Subject: [PATCH] Use the initialized pluggable plugin in post-scrapper if it's available. Otherwise, initiate a new Pluggable plugin. This is because in Elementor, pluggable is not available in the window --- packages/js/src/elementor/initializers/pluggable.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/js/src/elementor/initializers/pluggable.js b/packages/js/src/elementor/initializers/pluggable.js index 26b16565773..76a53c79f0f 100644 --- a/packages/js/src/elementor/initializers/pluggable.js +++ b/packages/js/src/elementor/initializers/pluggable.js @@ -1,3 +1,5 @@ +import { dispatch } from "@wordpress/data"; +import Pluggable from "../../lib/Pluggable"; // Holds the singleton used in getPluggable. let pluggable = null; @@ -8,8 +10,12 @@ let pluggable = null; */ const getPluggable = () => { if ( pluggable === null ) { - // Use the initialized pluggable plugin in post-scrapper. - pluggable = window.YoastSEO.app.pluggable; + // Use the initialized pluggable plugin in post-scrapper if it's available. + // Otherwise, initiate a new Pluggable plugin. + const refresh = dispatch( "yoast-seo/editor" ).runAnalysis; + pluggable = window.YoastSEO.app && window.YoastSEO.app.pluggable + ? window.YoastSEO.app.pluggable + : new Pluggable( refresh ); } return pluggable;