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