Skip to content

Commit

Permalink
Merge pull request #9 from newfold-labs/add/are-you-sure-interstitial
Browse files Browse the repository at this point in the history
Add an "Are you sure" interstitial
  • Loading branch information
circlecube authored Mar 18, 2024
2 parents 6706a53 + f706c8f commit 83447e2
Show file tree
Hide file tree
Showing 4 changed files with 573 additions and 260 deletions.
83 changes: 69 additions & 14 deletions includes/DeactivationSurvey.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace NewfoldLabs\WP\Module\Deactivation;

use NewfoldLabs\WP\ModuleLoader\Container;
use function NewfoldLabs\WP\ModuleLoader\container;

/**
Expand All @@ -18,6 +19,71 @@ class DeactivationSurvey {
* DeactivationSurvey constructor.
*/
public function __construct() {
// $this->container = $container;

$defaults = array(
'surveyAriaTitle' => __( 'Plugin Deactivation Survey', 'wp-module-deactivation' ),
'surveyTitle' => sprintf(
__( 'Thank you for using the %s plugin!', 'wp-module-deactivation' ),
ucwords( container()->plugin()->id )
),
'surveyDesc' => __( 'Please take a moment to let us know why you\'re deactivating this plugin.', 'wp-module-deactivation' ),
'formAriaLabel' => __( 'Plugin Deactivation Form', 'wp-module-deactivation' ),
'label' => __( 'Why are you deactivating this plugin?', 'wp-module-deactivation' ),
'placeholder' => __( 'Please share the reason here...', 'wp-module-deactivation' ),
'submit' => __( 'Submit & Deactivate', 'wp-module-deactivation' ),
'submitAriaLabel' => __( 'Submit and Deactivate Plugin', 'wp-module-deactivation' ),
'cancel' => __( 'Cancel', 'wp-module-deactivation' ),
'cancelAriaLabel' => __( 'Cancel Deactivation', 'wp-module-deactivation' ),
'skip' => __( 'Skip & Deactivate', 'wp-module-deactivation' ),
'skipAriaLabel' => __( 'Skip and Deactivate Plugin', 'wp-module-deactivation' ),
'continue' => __( 'Continue', 'wp-module-deactivation' ),
'continueAriaLabel' => __( 'Continue Deactivation', 'wp-module-deactivation' ),
'sureTitle' => __( 'Are you sure you want to deactivate?', 'wp-module-deactivation' ),
'sureDesc' => __( 'If the Bluehost plugin is deactivated, these features will no longer work:', 'wp-module-deactivation' ),
'sureCards' => array(
array(
'title' => sprintf(
__( '%s Caching', 'wp-module-deactivation' ),
ucwords( container()->plugin()->id )
),
'desc' => __( 'Automatically clears the server page cache when your site updates', 'wp-module-deactivation' ),
'condition' => true,
),
array(
'title' => sprintf(
__( '%s Staging', 'wp-module-deactivation' ),
ucwords( container()->plugin()->id )
),
'desc' => __( 'Create a staging copy of your site to safely test changes', 'wp-module-deactivation' ),
'condition' => true,
),
array(
'title' => __( 'WooCommerce Tools', 'wp-module-deactivation' ),
'desc' => __( 'Run campaigns and promotions on your store', 'wp-module-deactivation' ),
'condition' => 'window.NewfoldRuntime.isWoocommerceActive',
),
array(
'title' => __( 'Wonder Blocks & Patterns Library', 'wp-module-deactivation' ),
'desc' => __( 'Dozens of beautiful block templates and patterns', 'wp-module-deactivation' ),
'condition' => true,
),
),
'sureHelp' => sprintf(
__( 'Need Help? Check the <a href="%s">help center</a> for support.', 'wp-module-deactivation' ),
'/wp-admin/admin.php?page=' . container()->plugin()->id . '#/help'
),
);

// Merge defaults with container values from plugin
// $this->strings = wp_parse_args(
// $container->has( 'deactivation' ) ?
// $container['deactivation'] :
// array(),
// $defaults
// );
$this->strings = $defaults;

$this->deactivation_survey_assets();
$this->deactivation_survey_runtime();
}
Expand Down Expand Up @@ -60,6 +126,8 @@ public function deactivation_survey_assets() {
public function deactivation_survey_runtime() {
$plugin_slug = explode( '/', container()->plugin()->basename )[0];

// Validate strings->cards via condition

wp_localize_script(
'nfd-deactivation-survey',
'newfoldDeactivationSurvey',
Expand All @@ -68,20 +136,7 @@ public function deactivation_survey_runtime() {
'restApiNonce' => wp_create_nonce( 'wp_rest' ),
'brand' => container()->plugin()->id,
'pluginSlug' => $plugin_slug,
'strings' => array(
'surveyTitle' => __( 'Plugin Deactivation Survey', 'wp-module-deactivation' ),
'dialogTitle' => sprintf( __( 'Thank you for using the %s plugin!', 'wp-module-deactivation' ), ucwords( container()->plugin()->id ) ),
'dialogDesc' => __( 'Please take a moment to let us know why you\'re deactivating this plugin.', 'wp-module-deactivation' ),
'formAriaLabel' => __( 'Plugin Deactivation Form', 'wp-module-deactivation' ),
'label' => __( 'Why are you deactivating this plugin?', 'wp-module-deactivation' ),
'placeholder' => __( 'Please share the reason here...', 'wp-module-deactivation' ),
'submit' => __( 'Submit & Deactivate', 'wp-module-deactivation' ),
'submitAriaLabel' => __( 'Submit and Deactivate Plugin', 'wp-module-deactivation' ),
'cancel' => __( 'Cancel', 'wp-module-deactivation' ),
'cancelAriaLabel' => __( 'Cancel Deactivation', 'wp-module-deactivation' ),
'skip' => __( 'Skip & Deactivate', 'wp-module-deactivation' ),
'skipAriaLabel' => __( 'Skip and Deactivate Plugin', 'wp-module-deactivation' ),
),
'strings' => $this->strings,
)
);
}
Expand Down
Loading

0 comments on commit 83447e2

Please sign in to comment.