diff --git a/includes/DeactivationSurvey.php b/includes/DeactivationSurvey.php
index 7432d83..f6cb544 100644
--- a/includes/DeactivationSurvey.php
+++ b/includes/DeactivationSurvey.php
@@ -43,6 +43,7 @@ public function __construct() {
'continue' => __( 'Continue', 'wp-module-deactivation' ),
'continueAriaLabel' => __( 'Continue Deactivation', 'wp-module-deactivation' ),
'sureTitle' => __( 'Are you sure you want to deactivate?', 'wp-module-deactivation' ),
+ 'deactivating' => __( 'Deactivating', 'wp-module-deactivation' ),
'sureDesc' => sprintf(
__( 'If the %s plugin is deactivated, these features will no longer work:', 'wp-module-deactivation' ),
ucwords( container()->plugin()->id )
diff --git a/static/js/deactivation-survey.js b/static/js/deactivation-survey.js
index fdc7000..e508516 100644
--- a/static/js/deactivation-survey.js
+++ b/static/js/deactivation-survey.js
@@ -3,6 +3,7 @@
const runtimeData = window.newfoldDeactivationSurvey;
// Dialog instance / will be initialized later
let deactivationSurveyDialog;
+ let deactivateLink;
const renderDialog = () => {
// Create dialog container
@@ -122,12 +123,38 @@
return content;
};
+ const getDeactivatingContent = () => {
+ const content = `
+
+ `;
+ return content;
+ };
+
const getDialogHTML = () => {
const content = `
${ getSureContent() }
${ getSurveyContent() }
+ ${ getDeactivatingContent() }
`;
@@ -150,13 +177,25 @@
};
const deactivatePlugin = () => {
- destroyDialog();
// Get deactivation link and redirect
- const deactivateLink = document.getElementById(
- 'deactivate-' + runtimeData.pluginSlug
- ).href;
if ( deactivateLink ) {
window.location.href = deactivateLink;
+ const container = document.querySelector(
+ '.nfd-deactivation-survey__container'
+ );
+ const survey = document.querySelector( '.nfd-deactivation-survey' );
+ const goodbye = document.querySelector(
+ '.nfd-deactivation-goodbye'
+ );
+ // update container with data setp 3
+ container.setAttribute( 'data-step', '3' );
+
+ // hide interstitial are you sure page
+ survey.classList.add( 'nfd-hidden' );
+ survey.setAttribute( 'aria-hidden', true );
+ // display survey content
+ goodbye.classList.remove( 'nfd-hidden' );
+ goodbye.removeAttribute( 'aria-hidden' );
} else {
console.error( 'Error: Deactivation link not found.' );
}
@@ -192,10 +231,9 @@
isSubmitting();
// Send event
- return await sendSurveyEvent( skipped )
- .then( () => {
- deactivatePlugin();
- } );
+ return await sendSurveyEvent( skipped ).then( () => {
+ deactivatePlugin();
+ } );
};
/**
@@ -289,9 +327,13 @@
const wpAdmin = document.querySelector( 'body.wp-admin' );
wpAdmin.addEventListener( 'click', ( e ) => {
// Plugin deactivation listener
- if ( e.target.id === 'deactivate-' + runtimeData.pluginSlug ) {
+ if (
+ e.target.id.includes( 'deactivate-' ) &&
+ e.target.id.includes( window.NewfoldRuntime.plugin.brand )
+ ) {
e.preventDefault();
renderDialog();
+ deactivateLink = e.target.href;
}
// Remove dialog listener