1- /* global customElements, HTMLElement, prplL10n, progressPlannerAjaxRequest, prplSuggestedTask */
1+ /* global customElements, HTMLElement, prplL10n, progressPlanner, progressPlannerAjaxRequest, prplSuggestedTask */
22/*
33 * Install Plugin
44 *
@@ -19,7 +19,7 @@ customElements.define(
1919 action ,
2020 providerId ,
2121 className = 'prpl-button-link' ,
22- completeTask = 'true' // String on purpose, since element attributes are always strings.
22+ completeTaskAttr = 'true' // String on purpose, since element attributes are always strings.
2323 ) {
2424 // Get parent class properties
2525 super ( ) ;
@@ -30,8 +30,8 @@ customElements.define(
3030 pluginName ?? this . getAttribute ( 'data-plugin-name' ) ;
3131 this . pluginName = this . pluginName ?? this . pluginSlug ;
3232 this . action = action ?? this . getAttribute ( 'data-action' ) ;
33- this . completeTask =
34- completeTask ?? this . getAttribute ( 'data-complete-task' ) ;
33+ this . completeTaskAttr =
34+ completeTaskAttr ?? this . getAttribute ( 'data-complete-task' ) ;
3535 this . providerId =
3636 providerId ?? this . getAttribute ( 'data-provider-id' ) ;
3737 this . className = className ?? this . getAttribute ( 'class' ) ;
@@ -41,7 +41,7 @@ customElements.define(
4141 }
4242
4343 // Convert the string to a boolean.
44- this . completeTask = 'true' === this . completeTask ;
44+ this . completeTaskAttr = 'true' === this . completeTaskAttr ;
4545
4646 // Set the inner HTML.
4747 this . innerHTML = `
@@ -87,12 +87,12 @@ customElements.define(
8787 ` ;
8888
8989 progressPlannerAjaxRequest ( {
90- url : this . getAjaxUrl ( ) ,
90+ url : progressPlanner . ajaxUrl ,
9191 data : {
9292 action : 'progress_planner_install_plugin' ,
9393 plugin_slug : this . pluginSlug ,
9494 plugin_name : this . pluginName ,
95- nonce : this . getNonce ( ) ,
95+ nonce : progressPlanner . nonce ,
9696 } ,
9797 } )
9898 . then ( ( ) => thisObj . activatePlugin ( ) )
@@ -108,19 +108,19 @@ customElements.define(
108108 ` ;
109109
110110 progressPlannerAjaxRequest ( {
111- url : this . getAjaxUrl ( ) ,
111+ url : progressPlanner . ajaxUrl ,
112112 data : {
113113 action : 'progress_planner_activate_plugin' ,
114114 plugin_slug : thisObj . pluginSlug ,
115115 plugin_name : thisObj . pluginName ,
116- nonce : this . getNonce ( ) ,
116+ nonce : progressPlanner . nonce ,
117117 } ,
118118 } )
119119 . then ( ( ) => {
120120 button . innerHTML = prplL10n ( 'activated' ) ;
121121
122122 // Complete the task if the completeTask attribute is set to true.
123- if ( true === thisObj . completeTask ) {
123+ if ( true === thisObj . completeTaskAttr ) {
124124 thisObj . completeTask ( ) ;
125125 }
126126 } )
@@ -151,25 +151,5 @@ customElements.define(
151151 }
152152 } ) ;
153153 }
154-
155- /**
156- * Get the AJAX URL.
157- *
158- * @return {string } The AJAX URL.
159- */
160- getAjaxUrl ( ) {
161- return window . progressPlanner ?. ajaxUrl ?? window . ajaxurl ;
162- }
163-
164- /**
165- * Get the nonce.
166- *
167- * @return {string } The nonce.
168- */
169- getNonce ( ) {
170- return (
171- window . progressPlanner ?. nonce ?? window . prplSuggestedTask ?. nonce
172- ) ;
173- }
174154 }
175155) ;
0 commit comments