Skip to content

Commit

Permalink
Use the initialized pluggable plugin in post-scrapper if it's availa…
Browse files Browse the repository at this point in the history
…ble. Otherwise, initiate a new Pluggable plugin. This is because in Elementor, pluggable is not available in the window
  • Loading branch information
FAMarfuaty committed Nov 10, 2023
1 parent 6d8deba commit eb3d087
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/js/src/elementor/initializers/pluggable.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { dispatch } from "@wordpress/data";
import Pluggable from "../../lib/Pluggable";
// Holds the singleton used in getPluggable.
let pluggable = null;

Expand All @@ -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;
Expand Down

0 comments on commit eb3d087

Please sign in to comment.