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