| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
global $gf_feedback_custom_poll_id; |
| 5 |
global $gf_feedback_custom_poll_action_link; |
| 6 |
$gf_feedback_custom_poll_id = '14'; |
| 7 |
$gf_feedback_custom_poll_action_link = 'https://www.cozmoslabs.com/profile-builder-poll/'; |
| 8 |
|
| 9 |
/* add the modal on the plugin screen and embed a polldaddy form in it */ |
| 10 |
add_action( 'admin_footer', 'wppb_add_feedback_modal' ); |
| 11 |
function wppb_add_feedback_modal(){ |
| 12 |
global $current_screen; |
| 13 |
global $gf_feedback_custom_poll_id; |
| 14 |
global $gf_feedback_custom_poll_action_link; |
| 15 |
|
| 16 |
$gf_id = $gf_feedback_custom_poll_id; |
| 17 |
$action_link = $gf_feedback_custom_poll_action_link; |
| 18 |
|
| 19 |
if( $current_screen->base == 'plugins' ){ |
| 20 |
?> |
| 21 |
<div id="custom-feedback-modal"> |
| 22 |
|
| 23 |
<div class="custom-feedback-poll-content"> |
| 24 |
|
| 25 |
<h1 style="padding-left:10px;padding-top:15px;"><?php esc_html_e('Quick Feedback', 'profile-builder'); ?></h1> |
| 26 |
<p><?php esc_html_e( 'Because we care about our clients, please leave us feedback on why you are no longer using our plugin.', 'profile-builder'); ?></p> |
| 27 |
<form method="post" enctype="multipart/form-data" id="gform_<?php echo esc_attr( $gf_id ); ?>" class="gpoll_enabled gpoll" action="<?php echo esc_attr( $action_link ); ?>"> |
| 28 |
<div> |
| 29 |
<ul> |
| 30 |
<li> |
| 31 |
<input name="input_1" type="radio" value="gpoll1d7fc0436" id="choice_<?php echo esc_attr( $gf_id ); ?>_1_0"> |
| 32 |
<label for="choice_<?php echo esc_attr( $gf_id ); ?>_1_0" id="label_<?php echo esc_attr( $gf_id ); ?>_1_0"><?php esc_html_e( 'Lacking certain features', 'profile-builder'); ?></label> |
| 33 |
<input class="poll_custom_hidden_detail" name="input_2" id="input_<?php echo esc_attr( $gf_id ); ?>_2" type="text" value="" placeholder="<?php esc_html_e( 'What feature would you like to see?', 'profile-builder' ); ?>"> |
| 34 |
</li> |
| 35 |
<li> |
| 36 |
<input name="input_1" type="radio" value="gpoll19c993bd1" id="choice_<?php echo esc_attr( $gf_id ); ?>_1_1"> |
| 37 |
<label for="choice_<?php echo esc_attr( $gf_id ); ?>_1_1" id="label_<?php echo esc_attr( $gf_id ); ?>_1_1"><?php esc_html_e( 'Hard to use', 'profile-builder'); ?></label> |
| 38 |
<input class="poll_custom_hidden_detail" name="input_3" id="input_<?php echo esc_attr( $gf_id ); ?>_3" type="text" value="" placeholder="<?php esc_html_e( 'How can we improve our user experience ?', 'profile-builder' ); ?>"> |
| 39 |
</li> |
| 40 |
<li> |
| 41 |
<input name="input_1" type="radio" value="gpoll147502d8a" id="choice_<?php echo esc_attr( $gf_id ); ?>_1_2"> |
| 42 |
<label for="choice_<?php echo esc_attr( $gf_id ); ?>_1_2" id="label_<?php echo esc_attr( $gf_id ); ?>_1_2"><?php esc_html_e( 'Unsatisfactory support', 'profile-builder' ); ?></label> |
| 43 |
<span class="poll_custom_hidden_detail"><?php esc_html_e( "Give us another try! Open a support ticket <a href='https://www.cozmoslabs.com/support/open-ticket/' target='_blank'>here</a>", 'profile-builder' ) ?></span> |
| 44 |
</li> |
| 45 |
<li> |
| 46 |
<input name="input_1" type="radio" value="gpoll1353bb209" id="choice_<?php echo esc_attr( $gf_id ); ?>_1_4"> |
| 47 |
<label for="choice_<?php echo esc_attr( $gf_id ); ?>_1_4" id="label_<?php echo esc_attr( $gf_id ); ?>_1_4"><?php esc_html_e( 'Other', 'profile-builder'); ?></label> |
| 48 |
<input class="poll_custom_hidden_detail" name="input_4" id="input_<?php echo esc_attr( $gf_id ); ?>_4" type="text" value="" placeholder="<?php esc_html_e( 'Please tell us more', 'profile-builder' ); ?>"> |
| 49 |
</li> |
| 50 |
<li> |
| 51 |
<input name="input_1" type="radio" value="gpoll18cbe0189" id="choice_<?php echo esc_attr( $gf_id ); ?>_1_3"> |
| 52 |
<label for="choice_<?php echo esc_attr( $gf_id ); ?>_1_3" id="label_<?php echo esc_attr( $gf_id ); ?>_1_3"><?php esc_html_e( 'Poor Documentation', 'profile-builder'); ?></label> |
| 53 |
<input class="poll_custom_hidden_detail" name="input_5" id="input_<?php echo esc_attr( $gf_id ); ?>_5" type="text" value="" placeholder="<?php esc_html_e( "Tell us what you couldn't find", 'profile-builder' ); ?>"> |
| 54 |
</li> |
| 55 |
</ul> |
| 56 |
</div> |
| 57 |
<div class="gform_footer"> |
| 58 |
<input type="submit" id="gform_submit_button_<?php echo esc_attr( $gf_id ); ?>" class="button button-primary" value="<?php esc_html_e( 'Submit & Deactivate', 'profile-builder' ); ?>" disabled="disabled"> |
| 59 |
<input type="hidden" class="gform_hidden" name="is_submit_<?php echo esc_attr( $gf_id ); ?>" value="1"> |
| 60 |
<input type="hidden" class="gform_hidden" name="gform_submit" value="<?php echo esc_attr( $gf_id ); ?>"> |
| 61 |
<a href="#" class="button secondary custom-feedback-skip"><?php esc_html_e('Skip and Deactivate', 'profile-builder'); ?></a> |
| 62 |
</div> |
| 63 |
</form> |
| 64 |
|
| 65 |
|
| 66 |
</div> |
| 67 |
|
| 68 |
</div> |
| 69 |
<?php |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
/* add the scripts for the modal on the plugin screen */ |
| 74 |
add_action( 'admin_footer', 'wppb_add_feedback_script' ); |
| 75 |
function wppb_add_feedback_script(){ |
| 76 |
global $current_screen; |
| 77 |
global $gf_feedback_custom_poll_id; |
| 78 |
global $gf_feedback_custom_poll_action_link; |
| 79 |
$action_link = $gf_feedback_custom_poll_action_link; |
| 80 |
|
| 81 |
$gf_id = $gf_feedback_custom_poll_id; |
| 82 |
|
| 83 |
if( $current_screen->base == 'plugins' ) { |
| 84 |
?> |
| 85 |
<script> |
| 86 |
jQuery(function () { |
| 87 |
pluginSlug = 'profile-builder';// define the plugin slug here |
| 88 |
|
| 89 |
if (jQuery('tr[data-slug="' + pluginSlug + '"] .deactivate a').length != 0) { |
| 90 |
|
| 91 |
/* the conditional fields */ |
| 92 |
jQuery("#gform_<?php echo esc_attr( $gf_id ); ?> input[type='radio']").on('click', function(){ |
| 93 |
jQuery("#gform_<?php echo esc_attr( $gf_id ); ?> input[type='submit']").prop("disabled", false); |
| 94 |
jQuery( '.poll_custom_hidden_detail' ).hide(); |
| 95 |
jQuery( '.poll_custom_hidden_detail', jQuery(this).parent() ).show(); |
| 96 |
}); |
| 97 |
|
| 98 |
/* this is the deactivation link */ |
| 99 |
deactivationLink = jQuery('tr[data-slug="' + pluginSlug + '"] .deactivate a').attr('href'); |
| 100 |
|
| 101 |
/* show the modal when you click deactivate */ |
| 102 |
jQuery('tr[data-slug="' + pluginSlug + '"] .deactivate a').on('click', function (e){ |
| 103 |
e . preventDefault(); |
| 104 |
e . stopPropagation(); |
| 105 |
tb_show("Profile Builder Quick Feedback", "#TB_inline?width=740&height=500&inlineId=custom-feedback-modal"); |
| 106 |
jQuery('#TB_ajaxContent').closest('#TB_window').css({ height : "auto", top: "50%", marginTop: "-300px" }); |
| 107 |
}); |
| 108 |
|
| 109 |
/* on submit */ |
| 110 |
jQuery("#gform_<?php echo esc_attr( $gf_id ); ?>").on('submit', function(e) { |
| 111 |
var url = "<?php echo esc_url( $action_link ); ?>"; // the script where you handle the form input. |
| 112 |
|
| 113 |
jQuery.ajax({ |
| 114 |
type: "POST", |
| 115 |
url: url, |
| 116 |
data: jQuery("#gform_<?php echo esc_attr( $gf_id ); ?>").serialize(), // serializes the form's elements. |
| 117 |
complete: function() |
| 118 |
{ |
| 119 |
tb_remove(); |
| 120 |
window.location.href = deactivationLink; |
| 121 |
} |
| 122 |
}); |
| 123 |
|
| 124 |
e.preventDefault(); // avoid to execute the actual submit of the form. |
| 125 |
}); |
| 126 |
|
| 127 |
/* on skip */ |
| 128 |
jQuery('.custom-feedback-skip').on('click', function(e){ |
| 129 |
e.preventDefault(); |
| 130 |
self.parent.tb_remove(); |
| 131 |
window.location.href = deactivationLink; |
| 132 |
}); |
| 133 |
|
| 134 |
} |
| 135 |
}); |
| 136 |
</script> |
| 137 |
<?php |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
/* add styling for the modal */ |
| 142 |
add_action( 'admin_footer', 'wppb_add_feedback_style' ); |
| 143 |
function wppb_add_feedback_style(){ |
| 144 |
global $current_screen; |
| 145 |
if( $current_screen->base == 'plugins' ) { |
| 146 |
?> |
| 147 |
<style type="text/css"> |
| 148 |
#TB_window .pds-box{ |
| 149 |
border:0 !important; |
| 150 |
} |
| 151 |
#TB_window .pds-links{ |
| 152 |
display:none; |
| 153 |
} |
| 154 |
#TB_window .pds-question-top{ |
| 155 |
font-size:13px; |
| 156 |
font-weight:normal; |
| 157 |
} |
| 158 |
#TB_window .pds-answer{ |
| 159 |
border:0; |
| 160 |
} |
| 161 |
#TB_window .pds-vote-button span{ |
| 162 |
display:none; |
| 163 |
} |
| 164 |
#TB_window .pds-vote-button:after{ |
| 165 |
content:"<?php esc_html_e('Submit and Deactivate', 'profile-builder')?>"; |
| 166 |
} |
| 167 |
#TB_window .pds-vote-button{ |
| 168 |
padding: 6px 14px; |
| 169 |
line-height: normal; |
| 170 |
font-size: 14px; |
| 171 |
font-weight: normal; |
| 172 |
vertical-align: middle; |
| 173 |
height: auto; |
| 174 |
margin-bottom: 4px; |
| 175 |
background: #0085ba; |
| 176 |
border-color: #0073aa #006799 #006799; |
| 177 |
box-shadow: 0 1px 0 #006799; |
| 178 |
color: #fff; |
| 179 |
text-decoration: none; |
| 180 |
text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799; |
| 181 |
cursor: pointer; |
| 182 |
border-width: 1px; |
| 183 |
border-style: solid; |
| 184 |
-webkit-appearance: none; |
| 185 |
border-radius: 3px; |
| 186 |
} |
| 187 |
|
| 188 |
#custom-feedback-modal{ |
| 189 |
display: none; |
| 190 |
} |
| 191 |
|
| 192 |
.custom-feedback-poll-content{ |
| 193 |
font-size:15px; |
| 194 |
padding:0 10px; |
| 195 |
} |
| 196 |
|
| 197 |
.custom-feedback-poll-content h1{ |
| 198 |
padding-left: 0 !important; |
| 199 |
margin-left:0; |
| 200 |
} |
| 201 |
|
| 202 |
.custom-feedback-poll-content form ul li > *{ |
| 203 |
vertical-align: middle; |
| 204 |
} |
| 205 |
|
| 206 |
.custom-feedback-poll-content label{ |
| 207 |
line-height:27px; |
| 208 |
} |
| 209 |
|
| 210 |
.custom-feedback-poll-content span{ |
| 211 |
font-size: 13px; |
| 212 |
line-height:27px; |
| 213 |
} |
| 214 |
|
| 215 |
.custom-feedback-poll-content input[type='radio']{ |
| 216 |
margin-top:2px; |
| 217 |
} |
| 218 |
|
| 219 |
.custom-feedback-poll-content p{ |
| 220 |
margin-bottom:30px; |
| 221 |
} |
| 222 |
|
| 223 |
.custom-feedback-poll-content .gform_footer{ |
| 224 |
margin-top:25px; |
| 225 |
} |
| 226 |
|
| 227 |
.custom-feedback-poll-content .button-primary{ |
| 228 |
font-size:15px; |
| 229 |
} |
| 230 |
|
| 231 |
.custom-feedback-skip{ |
| 232 |
float: right; |
| 233 |
} |
| 234 |
|
| 235 |
.poll_custom_hidden_detail{ |
| 236 |
display:none; |
| 237 |
width:300px; |
| 238 |
margin-left:15px; |
| 239 |
} |
| 240 |
|
| 241 |
</style> |
| 242 |
<?php |
| 243 |
} |
| 244 |
} |