Skip to content

Commit b3ee315

Browse files
authored
Merge pull request #675 from ProgressPlanner/filip/v19/fix-plugin-dashboard
Fix missing JS global variable on WP Dashboard page
2 parents c3b2bdf + a3246da commit b3ee315

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

assets/js/web-components/prpl-install-plugin.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global customElements, HTMLElement, prplL10n, progressPlanner, progressPlannerAjaxRequest, prplSuggestedTask */
1+
/* global customElements, HTMLElement, prplL10n, progressPlannerAjaxRequest, prplSuggestedTask */
22
/*
33
* Install Plugin
44
*
@@ -81,12 +81,12 @@ customElements.define(
8181
`;
8282

8383
progressPlannerAjaxRequest( {
84-
url: progressPlanner.ajaxUrl,
84+
url: this.getAjaxUrl(),
8585
data: {
8686
action: 'progress_planner_install_plugin',
8787
plugin_slug: this.pluginSlug,
8888
plugin_name: this.pluginName,
89-
nonce: progressPlanner.nonce,
89+
nonce: this.getNonce(),
9090
},
9191
} )
9292
.then( () => thisObj.activatePlugin() )
@@ -102,12 +102,12 @@ customElements.define(
102102
`;
103103

104104
progressPlannerAjaxRequest( {
105-
url: progressPlanner.ajaxUrl,
105+
url: this.getAjaxUrl(),
106106
data: {
107107
action: 'progress_planner_activate_plugin',
108108
plugin_slug: thisObj.pluginSlug,
109109
plugin_name: thisObj.pluginName,
110-
nonce: progressPlanner.nonce,
110+
nonce: this.getNonce(),
111111
},
112112
} )
113113
.then( () => {
@@ -141,5 +141,25 @@ customElements.define(
141141
}
142142
} );
143143
}
144+
145+
/**
146+
* Get the AJAX URL.
147+
*
148+
* @return {string} The AJAX URL.
149+
*/
150+
getAjaxUrl() {
151+
return window.progressPlanner?.ajaxUrl ?? window.ajaxurl;
152+
}
153+
154+
/**
155+
* Get the nonce.
156+
*
157+
* @return {string} The nonce.
158+
*/
159+
getNonce() {
160+
return (
161+
window.progressPlanner?.nonce ?? window.prplSuggestedTask?.nonce
162+
);
163+
}
144164
}
145165
);

0 commit comments

Comments
 (0)