| 1 |
<?php |
| 2 |
|
| 3 |
namespace Leadin\admin; |
| 4 |
|
| 5 |
use Leadin\data\Portal_Options; |
| 6 |
use \Leadin\includes\utils as utils; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class responsible for rendering the deactivation feedback form. |
| 10 |
*/ |
| 11 |
class DeactivationForm { |
| 12 |
|
| 13 |
/** |
| 14 |
* Class constructor, adds necessary hooks. |
| 15 |
*/ |
| 16 |
public function __construct() { |
| 17 |
add_action( 'admin_footer', array( $this, 'add_feedback_form' ) ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Render deactivation feedback form on plugin page. |
| 22 |
*/ |
| 23 |
public function add_feedback_form() { |
| 24 |
if ( get_current_screen()->id === 'plugins' ) { |
| 25 |
// handlers and logic are added via jQuery in the frontend. |
| 26 |
?> |
| 27 |
<div id="leadin-feedback-container" style="display: none;"> |
| 28 |
<div class="leadin-feedback-header"> |
| 29 |
<h2><?php echo esc_html( __( "We're sorry to see you go", 'leadin' ) ); ?></h2> |
| 30 |
<div class="leadin-modal-close"> |
| 31 |
<svg class="leadin-close-svg" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"> |
| 32 |
<path class="leadin-close-path" d="M14.5,1.5l-13,13m0-13,13,13" transform="translate(-1 -1)"></path> |
| 33 |
</svg> |
| 34 |
</div> |
| 35 |
</div> |
| 36 |
<div class="leadin-feedback-body"> |
| 37 |
<div> |
| 38 |
<strong> |
| 39 |
<?php echo esc_html( __( "If you have a moment, please let us know why you're deactivating the plugin", 'leadin' ) ); ?> |
| 40 |
</strong> |
| 41 |
</div> |
| 42 |
<form id='leadin-deactivate-form' class="leadin-deactivate-form"> |
| 43 |
<?php |
| 44 |
$radio_buttons = array( |
| 45 |
"I can't sign up or log in", |
| 46 |
'The plugin is impacting website performance', |
| 47 |
"The plugin isn't working", |
| 48 |
"The plugin isn't useful", |
| 49 |
'Temporarily disabling or troubleshooting', |
| 50 |
'Other', |
| 51 |
); |
| 52 |
|
| 53 |
$radio_button_translations = array( |
| 54 |
__( "I can't sign up or log in", 'leadin' ), |
| 55 |
__( 'The plugin is impacting website performance', 'leadin' ), |
| 56 |
__( "The plugin isn't working", 'leadin' ), |
| 57 |
__( "The plugin isn't useful", 'leadin' ), |
| 58 |
__( 'Temporarily disabling or troubleshooting', 'leadin' ), |
| 59 |
__( 'Other', 'leadin' ), |
| 60 |
); |
| 61 |
|
| 62 |
$buttons_count = count( $radio_buttons ); |
| 63 |
for ( $i = 0; $i < $buttons_count; $i++ ) { |
| 64 |
?> |
| 65 |
<div class="leadin-radio-input-container"> |
| 66 |
<input |
| 67 |
type="radio" |
| 68 |
id="leadinFeedback<?php echo esc_attr( $i ); ?>" |
| 69 |
name="feedback" |
| 70 |
value="<?php echo esc_attr( $radio_buttons[ $i ] ); ?>" |
| 71 |
class="leadin-feedback-radio" |
| 72 |
required |
| 73 |
> |
| 74 |
<label for="leadinFeedback<?php echo esc_attr( $i ); ?>"> |
| 75 |
<?php echo esc_html( $radio_button_translations[ $i ] ); ?> |
| 76 |
</label> |
| 77 |
</div> |
| 78 |
<?php |
| 79 |
} |
| 80 |
?> |
| 81 |
<textarea name="details" class="leadin-feedback-text-area leadin-feedback-text-control" placeholder="<?php echo esc_html( __( 'Feedback', 'leadin' ) ); ?>"></textarea> |
| 82 |
<input type="hidden" name="portal_id" value="<?php echo esc_html( Portal_Options::get_portal_id() ); ?>"> |
| 83 |
<div class="leadin-button-container"> |
| 84 |
<button type="submit" id="leadin-feedback-submit" class="leadin-button leadin-primary-button leadin-loader-button"> |
| 85 |
<div class="leadin-loader-button-content"> |
| 86 |
<?php echo esc_html( __( 'Submit & deactivate', 'leadin' ) ); ?> |
| 87 |
</div> |
| 88 |
<div class="leadin-loader"></div> |
| 89 |
</button> |
| 90 |
<button type="button" id="leadin-feedback-skip" class="leadin-button leadin-secondary-button"> |
| 91 |
<?php echo esc_html( __( 'Skip & deactivate', 'leadin' ) ); ?> |
| 92 |
</button> |
| 93 |
</div> |
| 94 |
</form> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
<?php |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
|