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