feedback_form.php
105 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | function mo_firebase_auth_display_feedback_form() { |
| 5 | if ( 'plugins.php' != basename( $_SERVER['PHP_SELF'] ) ) { |
| 6 | return; |
| 7 | } |
| 8 | $deactivate_reasons = array( "Does not have the features I'm looking for", "Confusing Interface", |
| 9 | "Bugs in the plugin", "Unable to register", "Other Reasons" ); |
| 10 | wp_enqueue_style( 'wp-pointer' ); |
| 11 | wp_enqueue_script( 'wp-pointer' ); |
| 12 | wp_enqueue_script( 'utils' ); |
| 13 | wp_enqueue_style( 'mo_firebase_auth_admin_settings_style', plugin_dir_url( dirname(__FILE__) ) . 'admin/css/style.css'); |
| 14 | |
| 15 | ?> |
| 16 | </head> |
| 17 | <body> |
| 18 | <div id="firebase_auth_feedback_modal" class="mo_modal"> |
| 19 | <div class="mo_modal-content"> |
| 20 | <span class="mo_close">×</span> |
| 21 | <h3>Tell us what happened? </h3> |
| 22 | <form name="f" method="post" action="" id="mo_firebase_auth_feedback"> |
| 23 | <?php wp_nonce_field('mo_firebase_auth_feedback_form','mo_firebase_auth_feedback_field'); ?> |
| 24 | <input type="hidden" name="option" value="mo_firebase_auth_feedback"/> |
| 25 | <div> |
| 26 | <p style="margin-left:2%"> |
| 27 | <?php |
| 28 | foreach ( $deactivate_reasons as $deactivate_reason ) { ?> |
| 29 | <div class="radio" style="padding:1px;margin-left:2%"> |
| 30 | <label style="font-weight:normal;font-size:14.6px" for="<?php echo $deactivate_reason; ?>"> |
| 31 | <input type="radio" name="deactivate_reason_radio" value="<?php echo $deactivate_reason; ?>" |
| 32 | required> |
| 33 | <?php echo $deactivate_reason; ?></label> |
| 34 | </div> |
| 35 | <?php } ?> |
| 36 | <br> |
| 37 | <textarea id="query_feedback" name="query_feedback" rows="4" style="margin-left:2%;width: 330px" |
| 38 | placeholder="Write your query here"></textarea> |
| 39 | <br><br> |
| 40 | <div class="mo_modal-footer"> |
| 41 | <input type="submit" name="miniorange_feedback_submit" |
| 42 | class="button button-primary button-large" style="float: left;" value="Submit"/> |
| 43 | <input id="mo_skip" type="submit" name="miniorange_feedback_skip" |
| 44 | class="button button-primary button-large" style="float: right;" value="Skip"/> |
| 45 | </div> |
| 46 | </div> |
| 47 | </form> |
| 48 | <form name="f" method="post" action="" id="mo_feedback_form_close"> |
| 49 | <input type="hidden" name="option" value="mo_firebase_auth_skip_feedback"/> |
| 50 | </form> |
| 51 | </div> |
| 52 | </div> |
| 53 | <script> |
| 54 | jQuery('a[aria-label="Deactivate Firebase Authentication"]').click(function () { |
| 55 | var mo_modal = document.getElementById('firebase_auth_feedback_modal'); |
| 56 | var mo_skip = document.getElementById('mo_skip'); |
| 57 | var span = document.getElementsByClassName("mo_close")[0]; |
| 58 | mo_modal.style.display = "block"; |
| 59 | jQuery('input:radio[name="deactivate_reason_radio"]').click(function () { |
| 60 | var reason = jQuery(this).val(); |
| 61 | var query_feedback = jQuery('#query_feedback'); |
| 62 | query_feedback.removeAttr('required') |
| 63 | |
| 64 | if ( reason === "Does not have the features I'm looking for" ) { |
| 65 | query_feedback.attr( "placeholder", "Let us know what feature are you looking for" ); |
| 66 | |
| 67 | } else if ( reason === "Other Reasons:" ) { |
| 68 | query_feedback.attr( "placeholder", "Can you let us know the reason for deactivation" ); |
| 69 | query_feedback.prop( 'required', true ); |
| 70 | |
| 71 | } else if ( reason === "Bugs in the plugin" ) { |
| 72 | query_feedback.attr( "placeholder", "Can you please let us know about the bug in detail?" ); |
| 73 | |
| 74 | } else if ( reason === "Confusing Interface" ) { |
| 75 | query_feedback.attr( "placeholder", "Finding it confusing? let us know so that we can improve the interface" ); |
| 76 | |
| 77 | } else if ( reason === "Unable to register" ) { |
| 78 | query_feedback.attr( "placeholder", "Error while creating a new account? Can you please let us know the exact error?" ); |
| 79 | |
| 80 | } |
| 81 | |
| 82 | |
| 83 | }); |
| 84 | |
| 85 | |
| 86 | span.onclick = function () { |
| 87 | mo_modal.style.display = "none"; |
| 88 | jQuery('#mo_feedback_form_close').submit(); |
| 89 | } |
| 90 | mo_skip.onclick = function() { |
| 91 | mo_modal.style.display = "none"; |
| 92 | jQuery('#mo_feedback_form_close').submit(); |
| 93 | } |
| 94 | |
| 95 | window.onclick = function (event) { |
| 96 | if ( event.target == mo_modal ) { |
| 97 | mo_modal.style.display = "none"; |
| 98 | } |
| 99 | } |
| 100 | return false; |
| 101 | |
| 102 | }); |
| 103 | </script><?php |
| 104 | } |
| 105 | ?> |