firebase-authentication-admin-display.php
292 lines
| 1 | <?php |
| 2 | |
| 3 | function mo_firebase_auth_page_ui() { |
| 4 | ?> |
| 5 | |
| 6 | <div class="mo_firebase_auth_success_container" style="display:none;" id="mo_firebase_auth_success_container"> |
| 7 | <div class="alert alert-success alert-dismissable" id="mo_firebase_auth_success_alert" data-fade="3000"> |
| 8 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> |
| 9 | Configurations saved successfully. |
| 10 | </div> |
| 11 | </div> |
| 12 | <div class="mo_firebase_auth_error_container" style="display:none;" id="mo_firebase_auth_error_container"> |
| 13 | <div class="alert alert-danger alert-dismissable" id="mo_firebase_auth_error_alert" data-fade="3000"> |
| 14 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> |
| 15 | Please enter required fields. |
| 16 | </div> |
| 17 | </div> |
| 18 | |
| 19 | <div style="margin-left:20px;overflow:hidden"> |
| 20 | <div class="row" style="margin:15px"> |
| 21 | <img width="30px" src="<?php echo dirname(plugin_dir_url( __FILE__ ));?>/images/logo.png"><h5>miniOrange Firebase Authentication</h5> |
| 22 | </div> |
| 23 | |
| 24 | <div class="row"> |
| 25 | <div class="col-md-8"> |
| 26 | |
| 27 | <?php |
| 28 | $currenttab = ''; |
| 29 | if( isset( $_GET['tab'] ) ) { |
| 30 | $currenttab = sanitize_text_field(wp_unslash($_GET['tab'])); |
| 31 | } |
| 32 | |
| 33 | ?> |
| 34 | <ul class="row mo_firebase_authentication_nav"> |
| 35 | <a href="admin.php?page=mo_firebase_authentication&tab=configure_firebase_authentication"><li class="mo_firebase_authentication_nav_item <?php if($currenttab === '' || $currenttab === 'configure_firebase_authentication') echo 'active'; ?>">Configure</li></a> |
| 36 | <a href="admin.php?page=mo_firebase_authentication&tab=advance_settings"><li class="mo_firebase_authentication_nav_item <?php if($currenttab === 'advance_settings') echo 'active'; ?>">Advanced Settings</li></a> |
| 37 | <a href="admin.php?page=mo_firebase_authentication&tab=firebase_authentication_hooks"><li class="mo_firebase_authentication_nav_item <?php if($currenttab === 'firebase_authentication_hooks') echo 'active'; ?>">Hooks</li></a> |
| 38 | </ul> |
| 39 | |
| 40 | <?php |
| 41 | if($currenttab === '' || $currenttab === 'configure_firebase_authentication'){ |
| 42 | mo_firebase_authentication_configure_ui(); |
| 43 | } elseif ( $currenttab === 'advance_settings'){ |
| 44 | mo_firebase_authentication_integration_ui(); |
| 45 | } elseif ( $currenttab === 'firebase_authentication_hooks'){ |
| 46 | mo_firebase_authentication_hooks_ui(); |
| 47 | } |
| 48 | ?> |
| 49 | </div> |
| 50 | <div class="col-md-4"> |
| 51 | <div class="mo_firebase_auth_card" style="width:90%" > |
| 52 | <h4 style="margin-bottom:30px">Contact us</h4> |
| 53 | <p class="mo_firebase_auth_contact_us_p"><b>Need any help?<br>Just send us a query so we can help you.</b></p><br> |
| 54 | <form action="" method="POST"> |
| 55 | <?php wp_nonce_field('mo_firebase_auth_contact_us_form','mo_firebase_auth_contact_us_field'); ?> |
| 56 | <input type="hidden" name="option" value="mo_firebase_auth_contact_us"> |
| 57 | <div class="form-group"> |
| 58 | <input type="email" placeholder="Enter email here" class="form-control" name="mo_firebase_auth_contact_us_email" id="mo_firebase_auth_contact_us_email" required> |
| 59 | </div> |
| 60 | <div class="form-group"> |
| 61 | <input type="tel" id="mo_firebase_auth_contact_us_phone" pattern="[\+]\d{11,14}|[\+]\d{1,4}[\s]\d{9,10}" placeholder="Enter phone here" class="form-control" name="mo_firebase_auth_contact_us_phone"> |
| 62 | </div> |
| 63 | <div class="form-group"> |
| 64 | <textarea class="form-control" onkeypress="mo_firebase_auth_contact_us_valid_query(this)" onkeyup="mo_firebase_auth_contact_us_valid_query(this)" onblur="mo_firebase_auth_contact_us_valid_query(this)" name="mo_firebase_auth_contact_us_query" placeholder="Enter query here" rows="5" id="mo_firebase_auth_contact_us_query" required></textarea> |
| 65 | </div> |
| 66 | <input type="submit" class="btn btn-primary" style="width:130px;height:40px" value="Submit"> |
| 67 | </form> |
| 68 | <br> |
| 69 | <p class="mo_firebase_auth_contact_us_p"><b>If you want custom features in the plugin, just drop an email at<br><a href="mailto:info@xecurify.com">info@xecurify.com</a></b></p> |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | </div> |
| 74 | |
| 75 | <script> |
| 76 | jQuery("#mo_firebase_auth_contact_us_phone").intlTelInput(); |
| 77 | function mo_firebase_auth_contact_us_valid_query(f) { |
| 78 | !(/^[a-zA-Z?,.\(\)\/@ 0-9]*$/).test(f.value) ? f.value = f.value.replace( |
| 79 | /[^a-zA-Z?,.\(\)\/@ 0-9]/, '') : null; |
| 80 | } |
| 81 | |
| 82 | jQuery("#mo_firebase_auth_test_config_button").on("click", function(event) { |
| 83 | var test_username = document.forms["test_configuration_form"]["test_username"].value; |
| 84 | var test_password = document.forms["test_configuration_form"]["test_password"].value; |
| 85 | if( test_username == "" || test_password == "" ){ |
| 86 | return; |
| 87 | } |
| 88 | event.preventDefault(); |
| 89 | let url = "<?php echo site_url(); ?>/?mo_action=firebaselogin&test=true"; |
| 90 | jQuery("#mo_firebasetestconfig").attr("action", url); |
| 91 | let newwindow = window.open("about:blank", 'firebasetestconfig', 'location=yes,height=700,width=600,scrollbars=yes,status=yes'); |
| 92 | jQuery("#mo_firebasetestconfig").submit(); |
| 93 | }); |
| 94 | function mo_firebase_auth_showDiv(){ |
| 95 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "block"; |
| 96 | } |
| 97 | function mo_firebase_auth_hideDiv(){ |
| 98 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "none"; |
| 99 | } |
| 100 | function mo_firebase_auth_manageWCDiv(){ |
| 101 | var checkBox = document.getElementById("mo_firebase_auth_woocommerce_intigration"); |
| 102 | // Get the output text |
| 103 | var wcDiv = document.getElementById("mo_firebase_auth_register_firebase_div"); |
| 104 | |
| 105 | // If the checkbox is checked, display the output text |
| 106 | if (checkBox.checked == true){ |
| 107 | wcDiv.style.display = "block"; |
| 108 | } else { |
| 109 | wcDiv.style.display = "none"; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | </script> |
| 114 | <?php |
| 115 | } |
| 116 | |
| 117 | function mo_firebase_authentication_configure_ui(){ |
| 118 | |
| 119 | ?> |
| 120 | <div class="row"> |
| 121 | <div class="col-md-12"> |
| 122 | <div> |
| 123 | <div class="mo_firebase_auth_card" style="width:90%" > |
| 124 | <form action="" method="post" id="mo_enable_firebase_auth_form"> |
| 125 | <?php wp_nonce_field('mo_firebase_auth_enable_form','mo_firebase_auth_enable_field'); ?> |
| 126 | <div style="display:inline"><div style="display:inline-block;padding:0px 10px 10px 0px"><strong>Enable Firebase Authentication:</strong></div> |
| 127 | <div style="display:inline-block"><label class="mo_firebase_auth_switch"> |
| 128 | <input value="1" name="mo_enable_firebase_auth" type="checkbox" id="mo_enable_firebase_auth" <?php echo get_option('mo_enable_firebase_auth') ? 'checked' : '' ?>> |
| 129 | <span class="mo_firebase_auth_slider round"></span> |
| 130 | <input type="hidden" name="option" value="mo_enable_firebase_auth"> |
| 131 | </label> |
| 132 | </div> |
| 133 | <span style="float: right;">[ |
| 134 | <a href="https://plugins.miniorange.com/wordpress-firebase-authentication#firebaseauthentication" target="_blank">How to configure?</a> ]</span> |
| 135 | </div> |
| 136 | </form> |
| 137 | <form action="" method="post" id="mo_firebase_auth_form"> |
| 138 | <?php wp_nonce_field('mo_firebase_auth_config_form','mo_firebase_auth_config_field'); ?> |
| 139 | <div style="padding:5px;"></div>Allow login with |
| 140 | <input style="margin-left: 5px;"type="radio" name="disable_wordpress_login" id="disable_wordpress_login" <?php if(get_option('mo_enable_firebase_auth') == false){ echo '';}else {echo get_option('mo_firebase_auth_disable_wordpress_login') ? '' : 'checked';} ?> value="0"onclick="mo_firebase_auth_hideDiv();">Both Firebase and WordPress |
| 141 | <span style="padding-right:10px" ></span> |
| 142 | <input type="radio" name="disable_wordpress_login" id="disable_wordpress_login" <?php if(get_option('mo_enable_firebase_auth') == false){ echo '';}else {echo get_option('mo_firebase_auth_disable_wordpress_login') ? 'checked' : '';} ?> value="1"onclick="mo_firebase_auth_showDiv();">Only Firebase |
| 143 | <div style="padding:5px;"></div> |
| 144 | <div style="<?php if(get_option('mo_firebase_auth_disable_wordpress_login') == 1) echo "display: block";else echo "display: none";?>"id="mo_firebase_auth_enable_admin_wp_login_div"> |
| 145 | <p>Enabling Firebase login will restrict logins with only Firebase credentials and won't allow WP login. <b>Please enable this only after you have successfully tested your configuration</b> as the default WordPress login will stop working. |
| 146 | </p> |
| 147 | <input type="checkbox" id="mo_firebase_auth_enable_admin_wp_login" name="mo_firebase_auth_enable_admin_wp_login" value="1" <?php checked((esc_attr(get_option('mo_firebase_auth_enable_admin_wp_login')) === false) || (esc_attr(get_option('mo_firebase_auth_enable_admin_wp_login')) == 1));?> /> Allow Administrators to use WordPress login <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">Selecting this option will only allow Wordpress Administrators to log in.</div> </div> |
| 148 | <br> |
| 149 | </div> |
| 150 | <br> |
| 151 | <h6><font color="#FF0000">*</font><font color="#000000">Project Id</font> <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">Collect project Id from your firebase project</div> </div></h6> |
| 152 | <input style="width:60%"type="text" id="project_id" name="projectid" value= "<?php echo get_option( 'mo_firebase_auth_project_id' ); ?>" placeholder="Enter Project Id.." required=""> |
| 153 | <br><br> |
| 154 | <h6><font color="#FF0000">*</font><font color="#000000">API Key</font> <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">Collect API key from your firebase project</div> </div></h6> |
| 155 | <input style="width:60%"type="text" id="api_key" name="apikey" value="<?php echo get_option( 'mo_firebase_auth_api_key' ); ?>" placeholder="Enter your API Key.." required=""> |
| 156 | <br> |
| 157 | <br> |
| 158 | <input type="submit" class="btn btn-primary" style="width:170px;height:40px" name="verify_user" value=" Save Configuration" id = "mo_auth_configure_button"onclick="showAlert();"> |
| 159 | </form> |
| 160 | </div> |
| 161 | </div> |
| 162 | <div> |
| 163 | <div class="mo_firebase_auth_card" style="width:90%" > |
| 164 | <h4 style="margin-bottom:30px">Test Authentication</h4> |
| 165 | <form name="test_configuration_form" id="mo_firebasetestconfig" method="post" target="firebasetestconfig"> |
| 166 | <?php wp_nonce_field('mo_firebase_auth_test_config_form','mo_firebase_auth_test_config_field'); ?> |
| 167 | <input type="hidden" name="option" value="mo_firebase_auth_test_configuration"> |
| 168 | <font color="#FF0000">* </font><input type="text" id="test_username" name="test_username" value="" placeholder="Username" style="margin-bottom:30px;width:35%;" required=""> <br> |
| 169 | <font color="#FF0000">* </font><input type="password" id="test_password" name="test_password" value="" placeholder="Password" style="margin-bottom:30px;width:35%;" required=""> <br> |
| 170 | <input type="hidden" id="test_check_field" name="test_check_field" value="test_check_true"> |
| 171 | <input type="submit" class="btn btn-primary" id="mo_firebase_auth_test_config_button" style="width:170px;height:40px" name="test_configuration" value="Test Authentication" <?php if( ! get_option( 'mo_firebase_auth_project_id' ) && ! get_option( 'mo_firebase_auth_api_key' ) ) echo 'disabled' ?> > |
| 172 | </form> |
| 173 | </div> |
| 174 | </div> |
| 175 | </div> |
| 176 | </div> |
| 177 | <?php |
| 178 | } |
| 179 | |
| 180 | function mo_firebase_authentication_integration_ui(){ |
| 181 | ?> |
| 182 | <div class="row"> |
| 183 | <div class="col-md-12"> |
| 184 | <div class="mo_firebase_auth_card" style="width:90%"> |
| 185 | <form name="integration_form" id="mo_firebase_auth_integration" method="post"> |
| 186 | <input type="hidden" name="option" value="mo_firebase_auth_integration"> |
| 187 | <h6><b>Sync WordPress and Firebase users</b><small style="color: #FF0000"> [PREMIUM]</small></h6><br> |
| 188 | |
| 189 | <div style="display:inline-block"><label class="mo_firebase_auth_switch"> |
| 190 | <input value="1" name="mo_enable_firebase_auto_register" type="checkbox" id="mo_enable_firebase_auto_register" disabled> |
| 191 | <span class="mo_firebase_auth_slider round"></span> |
| 192 | <input type="hidden" name="option" value=""> |
| 193 | </label> |
| 194 | </div> |
| 195 | <strong>Auto register users into Firebase</strong> |
| 196 | <br> |
| 197 | <h8>Enabling this option will create new user in Firebase project when a user registers in WordPress site.</h8> |
| 198 | </form> |
| 199 | </div> |
| 200 | </div> |
| 201 | </div> |
| 202 | <div class="row"> |
| 203 | <div class="col-md-12"> |
| 204 | <div class="mo_firebase_auth_card" style="width:90%"> |
| 205 | <form name="integration_form" id="mo_firebase_auth_integration" method="post"> |
| 206 | <input type="hidden" name="option" value="mo_firebase_auth_integration"> |
| 207 | <h6><b>Login & Registeration Form Integration</b><small style="color: #FF0000"> [PREMIUM]</small></h6><br> |
| 208 | <h8>Select below if you want to allow users to login using firebase credentials with third party or custom login/registration page.</h8><br><br> |
| 209 | <input type="checkbox" name = "mo_firebase_auth_woocommerce_intigration" id = "mo_firebase_auth_woocommerce_intigration" value= "1" onclick="mo_firebase_auth_manageWCDiv();" disabled> |
| 210 | <img src="<?php echo dirname(plugin_dir_url( __FILE__ ));?>/images/woocommerce-circle.png" width="50px"> |
| 211 | WooCommerce |
| 212 | <br><br> |
| 213 | <input type="checkbox" name = "mo_firebase_auth_buddypress_intigration"value="1" disabled> |
| 214 | <img src="<?php echo dirname(plugin_dir_url( __FILE__ ));?>/images/buddypress.png" width="50px"> BuddyPress |
| 215 | <br><br> |
| 216 | <input type="checkbox" name = "mo_firebase_auth_buddypress_intigration"value="1" disabled>Custom Login Form <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">Select if you have any custom login or registeration form or using any other third party plugin to create these forms.</div> </div> |
| 217 | <br> |
| 218 | <p style="font-size: 15px;margin-left: 10px;">You can select this option if you have any custom login or registeration form or using any other third party plugin to create these forms.</p> |
| 219 | <br><br> |
| 220 | <input type="submit" style="text-align:center;"class="btn btn-primary" style="width:120px;height:40px" name="integration_settings" value=" Save Settings" id = "mo_auth_integration_save_settings_button" disabled><br> |
| 221 | </form> |
| 222 | </div> |
| 223 | </div> |
| 224 | </div> |
| 225 | <div class="row"> |
| 226 | <div class="col-md-12"> |
| 227 | <div class="mo_firebase_auth_card" style="width:90%"> |
| 228 | <form name="integration_form" id="mo_firebase_auth_integration" method="post"> |
| 229 | <input type="hidden" name="option" value="mo_firebase_auth_integration"> |
| 230 | <h6><b>Firebase Authentication methods</b><small style="color: #FF0000"> [PREMIUM]</small></h6><br> |
| 231 | <h8>Select any one method to Login into your site using one of the Firebase Authentication method. </h8><br><br> |
| 232 | <!-- <input type="radio" id="emailPassword" value="emailPassword" disabled> |
| 233 | <label for="male">Email and Password</label><br> --> |
| 234 | <input type="radio" id="google" value="google" disabled> |
| 235 | <label for="female">Google</label><br> |
| 236 | <input type="radio" id="facebook" value="facebook" disabled> |
| 237 | <label for="other">Facebook</label><br> |
| 238 | <input type="radio" id="github" value="github" disabled> |
| 239 | <label for="other">GitHub</label><br> |
| 240 | <input type="radio" id="twitter" value="twitter" disabled> |
| 241 | <label for="other">Twitter</label><br> |
| 242 | <input type="radio" id="phone" value="phone" disabled> |
| 243 | <label for="other">Phone</label><br><br> |
| 244 | <input type="submit" style="text-align:center;"class="btn btn-primary" style="width:120px;height:40px" name="authentication_settings" value=" Save Settings" id = "mo_auth_authentication_save_settings_button" disabled><br> |
| 245 | <hr> |
| 246 | <p style="font-size: 12px">All the Firebase Authentication methods, Login/Registration form integrations, WordPress and Firebase user sync are available in the <b>premium</b> plugin version. Please email us at <b>info@xecurify.com</b> for more details.</p> |
| 247 | </form> |
| 248 | </div> |
| 249 | </div> |
| 250 | </div> |
| 251 | <?php |
| 252 | |
| 253 | } |
| 254 | |
| 255 | function mo_firebase_authentication_hooks_ui(){ |
| 256 | ?> |
| 257 | <div class="row"> |
| 258 | <div class="col-md-12"> |
| 259 | <div class="mo_firebase_auth_card" style="width:90%"> |
| 260 | We provide multiple hooks to extend the plugin functionality.<small style="color: #FF0000"> [PREMIUM]</small><br><br> |
| 261 | <div id="mo_firebase_authentication_hooks_table"> |
| 262 | <div id="mo_firebase_authentication_hook_item"> |
| 263 | <code>mo_firebase_wplogin_form_start</code><br> |
| 264 | <p id="mo_firebase_authentication_hook_item_desc">Used to perform action before WordPress login form.</p> |
| 265 | </div> |
| 266 | <br> |
| 267 | <div id="mo_firebase_authentication_hook_item"> |
| 268 | <code>mo_firebase_wplogin_form_end</code><br> |
| 269 | <p id="mo_firebase_authentication_hook_item_desc">Used to perform action when WordPress login form ends.</p> |
| 270 | </div> |
| 271 | <br> |
| 272 | <div id="mo_firebase_authentication_hook_item"> |
| 273 | <code>mo_firebase_user_attributes</code><br> |
| 274 | <p id="mo_firebase_authentication_hook_item_desc">Used to fetch user attributes received from firebase.</p> |
| 275 | </div> |
| 276 | <br> |
| 277 | <div id="mo_firebase_authentication_hook_item"> |
| 278 | <code>mo_firebase_get_jwt_token</code><br> |
| 279 | <p id="mo_firebase_authentication_hook_item_desc">Used to fetch and store JWT token received from firebase.</p> |
| 280 | </div> |
| 281 | <br> |
| 282 | <div id="mo_firebase_authentication_hook_item"> |
| 283 | <code>mo_firebase_enqueue_initialize_scripts</code><br> |
| 284 | <p id="mo_firebase_authentication_hook_item_desc">You can use this hook in your code to initialize firebase.</p> |
| 285 | </div> |
| 286 | <br> |
| 287 | </div> |
| 288 | </div> |
| 289 | </div> |
| 290 | </div> |
| 291 | <?php |
| 292 | } |