Changeset 3472376
- Timestamp:
- 03/02/2026 06:40:22 AM (4 weeks ago)
- Location:
- otpfy-your-website
- Files:
-
- 52 added
- 6 edited
-
tags/1.2.0 (added)
-
tags/1.2.0/LICENSE.txt (added)
-
tags/1.2.0/README.txt (added)
-
tags/1.2.0/admin (added)
-
tags/1.2.0/admin/class-otpfy-for-wordpress-admin.php (added)
-
tags/1.2.0/admin/css (added)
-
tags/1.2.0/admin/css/bulma.min.css (added)
-
tags/1.2.0/admin/css/jquery.dataTables.min.css (added)
-
tags/1.2.0/admin/css/otpfy-deactivation-popup.css (added)
-
tags/1.2.0/admin/css/otpfy-for-wordpress-admin.css (added)
-
tags/1.2.0/admin/images (added)
-
tags/1.2.0/admin/images/Bitss-Techniques-Logo-80x80.png (added)
-
tags/1.2.0/admin/index.php (added)
-
tags/1.2.0/admin/js (added)
-
tags/1.2.0/admin/js/jquery.dataTables.min.js (added)
-
tags/1.2.0/admin/js/otpfy-for-wordpress-admin-topbar.js (added)
-
tags/1.2.0/admin/js/otpfy-for-wordpress-admin.js (added)
-
tags/1.2.0/admin/partials (added)
-
tags/1.2.0/admin/partials/otpfy-deactivation-popup.php (added)
-
tags/1.2.0/admin/partials/otpfy-for-wordpress-admin-display.php (added)
-
tags/1.2.0/includes (added)
-
tags/1.2.0/includes/class-otpfy-for-wordpress-activator.php (added)
-
tags/1.2.0/includes/class-otpfy-for-wordpress-core.php (added)
-
tags/1.2.0/includes/class-otpfy-for-wordpress-deactivator.php (added)
-
tags/1.2.0/includes/class-otpfy-for-wordpress-i18n.php (added)
-
tags/1.2.0/includes/class-otpfy-for-wordpress-loader.php (added)
-
tags/1.2.0/includes/class-otpfy-for-wordpress.php (added)
-
tags/1.2.0/includes/index.php (added)
-
tags/1.2.0/includes/models (added)
-
tags/1.2.0/includes/models/class-otpfy-for-wordpress-settings.php (added)
-
tags/1.2.0/index.php (added)
-
tags/1.2.0/languages (added)
-
tags/1.2.0/languages/otpfy-for-wordpress.pot (added)
-
tags/1.2.0/otpfy-for-wordpress.php (added)
-
tags/1.2.0/public (added)
-
tags/1.2.0/public/class-otpfy-for-wordpress-public.php (added)
-
tags/1.2.0/public/css (added)
-
tags/1.2.0/public/css/otpfy-for-wordpress-public.css (added)
-
tags/1.2.0/public/css/snapotp.css (added)
-
tags/1.2.0/public/index.php (added)
-
tags/1.2.0/public/js (added)
-
tags/1.2.0/public/js/otpfy-checkout.js (added)
-
tags/1.2.0/public/js/otpfy-for-wordpress-public.js (added)
-
tags/1.2.0/public/js/snapotp.js (added)
-
tags/1.2.0/public/partials (added)
-
tags/1.2.0/public/partials/otpfy-checkout-mobile-verify-form.php (added)
-
tags/1.2.0/public/partials/otpfy-for-wordpress-public-display.php (added)
-
tags/1.2.0/public/template (added)
-
tags/1.2.0/public/template/woocommerce (added)
-
tags/1.2.0/public/template/woocommerce/checkout-login.php (added)
-
tags/1.2.0/public/template/woocommerce/my-account-login.php (added)
-
tags/1.2.0/uninstall.php (added)
-
trunk/includes/class-otpfy-for-wordpress.php (modified) (1 diff)
-
trunk/otpfy-for-wordpress.php (modified) (2 diffs)
-
trunk/public/class-otpfy-for-wordpress-public.php (modified) (4 diffs)
-
trunk/public/css/otpfy-for-wordpress-public.css (modified) (3 diffs)
-
trunk/public/js/otpfy-for-wordpress-public.js (modified) (2 diffs)
-
trunk/public/partials/otpfy-for-wordpress-public-display.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
otpfy-your-website/trunk/includes/class-otpfy-for-wordpress.php
r3340312 r3472376 230 230 $this->loader->add_action( 'wp_ajax_otpfy_checkout_verify_otp', $plugin_public, 'wp_ajax_otpfy_checkout_verify_otp' ); 231 231 $this->loader->add_action( 'wp_ajax_nopriv_otpfy_checkout_verify_otp', $plugin_public, 'wp_ajax_otpfy_checkout_verify_otp' ); 232 } 232 233 $this->loader->add_action( 'wp_ajax_api_call_register_and_login', $plugin_public, 'api_call_register_and_login' ); 234 $this->loader->add_action( 'wp_ajax_nopriv_api_call_register_and_login', $plugin_public, 'api_call_register_and_login' ); 235 } 236 233 237 234 238 /** -
otpfy-your-website/trunk/otpfy-for-wordpress.php
r3384409 r3472376 12 12 * Plugin URI: https://otpfy.in 13 13 * Description: OTPfy almost anything in your wordpress website!! OTP based Login, Signup, Order Confirmation, just anything you can imagine. Integrate OTP based 2 factor authentication using our developer hooks. 14 * Version: 1. 0.3.514 * Version: 1.2.0 15 15 * Author: Bitss Techniques 16 16 * Author URI: https://bitss.tech … … 31 31 * Rename this for your plugin and update it as you release new versions. 32 32 */ 33 define( 'OTPFY_FOR_WORDPRESS_VERSION', '1. 0.3.5' );33 define( 'OTPFY_FOR_WORDPRESS_VERSION', '1.2.0' ); 34 34 35 35 /** -
otpfy-your-website/trunk/public/class-otpfy-for-wordpress-public.php
r3384409 r3472376 118 118 "send_login_otp_nonce" => wp_create_nonce('api_call_send_verification_code'), 119 119 "vf_login_otp_nonce" => wp_create_nonce('api_call_verification_code'), 120 // "test_conn_nonce" => wp_create_nonce('api_call_for_test_connection'), 121 // "test_conn_nonce" => wp_create_nonce('api_call_for_test_connection'), 122 120 "register_and_login_nonce" => wp_create_nonce('api_call_register_and_login'), 123 121 ) 124 122 ); … … 264 262 265 263 } 266 264 265 // --- No account found: send OTP for registration flow --- 266 if ($user == false || $user == null) { 267 $otp = wp_rand(100000, 999999); 268 $otp_reg_arr = array( 269 "otp" => $otp, 270 "phone" => $value, 271 "otp_login_redirect" => $otp_login_redirect, 272 ); 273 set_transient( 'otpfy_noreg_' . $value, $otp_reg_arr, 10 * MINUTE_IN_SECONDS ); 274 $this->core->send_otp_for_verify( $otp, $value, '' ); 275 $response = array( 276 "status" => true, 277 "user_not_found" => true, 278 "data" => null, 279 "message" => "OTP sent! Please fill in your details to create an account.", 280 ); 281 wp_send_json($response); 282 die(); 283 } 284 267 285 //check if woocommerce plugin is active 268 286 … … 297 315 $this->core->send_otp_for_verify($otp,$phone,$email ); 298 316 299 //$response_code = wp_remote_retrieve_response_code( $response );300 // $body = json_decode( wp_remote_retrieve_body( $resp ), true );301 302 317 $response = array( 303 318 "status" => true, … … 310 325 die(); 311 326 327 } 328 329 /** 330 * AJAX: Verify OTP and register a new user, then auto-login. 331 * Action: api_call_register_and_login 332 */ 333 function api_call_register_and_login() { 334 335 if ( ! wp_verify_nonce( sanitize_text_field( $_GET['nonce'] ?? '' ), 'api_call_register_and_login' ) ) { 336 wp_send_json( array( 'status' => false, 'message' => 'Security check failed.' ) ); 337 die(); 338 } 339 340 $phone = sanitize_text_field( trim( $_GET['phone'] ?? '' ) ); 341 $otp = absint( trim( $_GET['otp'] ?? '' ) ); 342 $first_name = sanitize_text_field( trim( $_GET['first_name'] ?? '' ) ); 343 $email = sanitize_email( trim( $_GET['email'] ?? '' ) ); 344 345 // Validate required fields 346 if ( empty( $phone ) || empty( $otp ) || empty( $first_name ) || empty( $email ) ) { 347 wp_send_json( array( 'status' => false, 'message' => 'All fields are required.' ) ); 348 die(); 349 } 350 351 if ( ! is_email( $email ) ) { 352 wp_send_json( array( 'status' => false, 'message' => 'Please enter a valid email address.' ) ); 353 die(); 354 } 355 356 if ( email_exists( $email ) ) { 357 wp_send_json( array( 'status' => false, 'message' => 'An account with this email already exists. Please login instead.' ) ); 358 die(); 359 } 360 361 // Verify OTP 362 $otp_reg_arr = get_transient( 'otpfy_noreg_' . $phone ); 363 if ( false === $otp_reg_arr ) { 364 wp_send_json( array( 'status' => false, 'message' => 'OTP expired. Please go back and request a new one.' ) ); 365 die(); 366 } 367 if ( intval( $otp_reg_arr['otp'] ) !== $otp ) { 368 wp_send_json( array( 'status' => false, 'message' => 'Invalid OTP. Please try again.' ) ); 369 die(); 370 } 371 372 // Create user 373 $username = sanitize_user( $email ); 374 // Ensure username is unique 375 if ( username_exists( $username ) ) { 376 $username = $username . '_' . wp_rand( 100, 999 ); 377 } 378 379 $user_id = wp_create_user( $username, wp_generate_password(), $email ); 380 if ( is_wp_error( $user_id ) ) { 381 wp_send_json( array( 'status' => false, 'message' => $user_id->get_error_message() ) ); 382 die(); 383 } 384 $user = new WP_User( $user_id ); 385 386 if ( class_exists( 'WooCommerce' ) ) { 387 $user->set_role( 'customer' ); 388 } else { 389 $user->set_role( 'subscriber' ); 390 } 391 392 // Save user meta 393 update_user_meta( $user_id, 'first_name', $first_name ); 394 update_user_meta( $user_id, 'bt_otpfy_user_mobile_number', $phone ); 395 wp_update_user( array( 'ID' => $user_id, 'display_name' => $first_name ) ); 396 397 // WooCommerce billing meta 398 if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 399 update_user_meta( $user_id, 'billing_first_name', $first_name ); 400 update_user_meta( $user_id, 'billing_phone', $phone ); 401 update_user_meta( $user_id, 'billing_email', $email ); 402 } 403 404 // Clean up transient 405 delete_transient( 'otpfy_noreg_' . $phone ); 406 407 // Auto-login 408 $u_data = get_userdata( $user_id ); 409 wp_clear_auth_cookie(); 410 wp_set_current_user( $user_id ); 411 wp_set_auth_cookie( $user_id, true ); 412 do_action( 'wp_login', $u_data->user_login, $u_data ); 413 414 // Redirect 415 $otp_login_redirect_reg = isset( $otp_reg_arr['otp_login_redirect'] ) && ! empty( $otp_reg_arr['otp_login_redirect'] ) 416 ? wp_validate_redirect( $otp_reg_arr['otp_login_redirect'], '' ) 417 : ''; 418 if ( ! $otp_login_redirect_reg ) { 419 $otp_login_redirect_reg = get_permalink( $this->settings->get_redirect_url_after_login() ); 420 } 421 if ( ! $otp_login_redirect_reg ) { 422 $otp_login_redirect_reg = $this->get_next_page_url_based_on_user_role( $user_id ); 423 } 424 425 wp_send_json( array( 426 'status' => true, 427 'data' => $otp_login_redirect_reg, 428 'message' => 'Registration successful! Logging you in...', 429 ) ); 430 die(); 312 431 } 313 432 -
otpfy-your-website/trunk/public/css/otpfy-for-wordpress-public.css
r3228487 r3472376 49 49 } 50 50 #bt_otpfy_email_phone_input::placeholder, 51 .registration_details::placeholder, 51 52 #bt_otpfy_vf_code_input::placeholder { 52 53 text-align: center; … … 57 58 58 59 #bt_otpfy_email_phone_input, 60 .registration_details, 59 61 #bt_otpfy_vf_code_input { 60 margin: 10px 0px 5px 0px ;61 border-radius: 15px ;62 border: 1px solid black ;62 margin: 10px 0px 5px 0px !important; 63 border-radius: 15px !important; 64 border: 1px solid black !important; 63 65 font-size: 15px !important; 64 66 line-height: 10px !important; 65 padding: 10px ;67 padding: 10px !important; 66 68 width: 100%; 67 box-sizing: border-box ;68 height: 40px ;69 text-align: center ;69 box-sizing: border-box !important; 70 height: 40px !important; 71 text-align: center !important; 70 72 } 71 73 72 74 /* Chrome, Safari, Edge, Opera */ 73 75 #bt_otpfy_vf_code_input::-webkit-outer-spin-button, 76 .registration_details::-webkit-outer-spin-button, 77 .registration_details::-webkit-inner-spin-button, 74 78 #bt_otpfy_vf_code_input::-webkit-inner-spin-button { 75 79 -webkit-appearance: none; … … 77 81 } 78 82 /* Firefox */ 83 .registration_details[type="number"] , 79 84 #bt_otpfy_vf_code_input[type="number"] { 80 85 -moz-appearance: textfield; 81 86 } 82 87 #bt_otpfy_email_phone_input:focus, 88 .registration_details:focus, 83 89 #bt_otpfy_vf_code_input:focus { 84 90 border: 1px solid black; -
otpfy-your-website/trunk/public/js/otpfy-for-wordpress-public.js
r3228487 r3472376 1 (function ( $) {1 (function ($) { 2 2 'use strict'; 3 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 $(document).ready(function(){ 32 $('body').on('click', '#bt_otpfy_send_vf_code_btn', function(e) { 33 e.preventDefault(); 4 var isNewUser = false; // tracks whether the current OTP step is for a new user 5 6 $(document).ready(function () { 7 8 // ── Step 1: Send OTP ───────────────────────────────────────────────── 9 $('body').on('click', '#bt_otpfy_send_vf_code_btn', function (e) { 10 e.preventDefault(); 34 11 $('#bt_otpfy_send_vf_code_btn').prop("disabled", true); 35 12 $('#bt_otpfy_send_server_mess').html(''); 36 13 $("#bt_otpfy_send_loader").addClass("btn-ring"); 37 var value = $("#bt_otpfy_email_phone_input").val();14 var value = $("#bt_otpfy_email_phone_input").val(); 38 15 api_call_send_vf_otp(value); 39 16 }); 40 17 41 $('body').on('click', '#bt_otpfy_vf_code_btn', function(e) { 18 // ── Step 2: Unified verify / register button ────────────────────────── 19 $('body').on('click', '#bt_otpfy_vf_code_btn', function (e) { 42 20 e.preventDefault(); 43 21 $('#bt_otpfy_vf_code_btn').prop("disabled", true); 44 22 $('#bt_otpfy_vf_server_mess').html(''); 45 23 $("#bt_otpfy_vf_loader").addClass("btn-ring"); 46 $('#bt_otpfy_vf_code_btn').html("Verifying..."); 47 var value = $("#bt_otpfy_email_phone_input").val(); 48 var code = $("#bt_otpfy_vf_code_input").val(); 49 api_call_vf_otp(value, code); 50 }); 51 52 $('body').on('click', '#bt_otpfy_resend_otp', function(e) { 53 e.preventDefault(); 54 $('#bt_otpfy_resend_otp').addClass("bt_otpfy_disabled"); 55 $('#bt_otpfy_send_server_mess').html(''); 56 var value = $("#bt_otpfy_email_phone_input").val(); 57 api_call_send_vf_otp(value); 24 25 var phone = $("#bt_otpfy_email_phone_input").val(); 26 var otp = $("#bt_otpfy_vf_code_input").val(); 27 28 if (isNewUser) { 29 // Registration mode 30 $('#bt_otpfy_vf_code_btn').html("Registering..."); 31 var first_name = $.trim($("#bt_otpfy_reg_first_name").val()); 32 var email = $.trim($("#bt_otpfy_reg_email").val()); 33 api_call_register_and_login(phone, first_name, email, otp); 34 } else { 35 // Login mode 36 $('#bt_otpfy_vf_code_btn').html("Verifying..."); 37 api_call_vf_otp(phone, otp); 38 } 39 }); 40 41 // ── Resend OTP ─────────────────────────────────────────────────────── 42 $('body').on('click', '#bt_otpfy_resend_otp', function (e) { 43 e.preventDefault(); 44 if ($(this).hasClass("bt_otpfy_disabled")) return; 45 $('#bt_otpfy_resend_otp').addClass("bt_otpfy_disabled"); 46 $('#bt_otpfy_vf_server_mess').html(''); 47 var value = $("#bt_otpfy_email_phone_input").val(); 48 api_call_send_vf_otp(value); 58 49 clearInterval(interval); 59 50 }); 60 61 $('body').on('click', '#bt_otpfy_back_to_send_login_otp', function(e) { 51 52 // ── Go back ────────────────────────────────────────────────────────── 53 $('body').on('click', '#bt_otpfy_back_to_send_login_otp', function (e) { 62 54 e.preventDefault(); 63 55 $('#bt_otpfy_send_server_mess').html(''); 64 56 $('#bt_otpfy_vf_server_mess').html(''); 65 57 $("#bt_otpfy_send_otp_div").removeClass("bt_otpfy_hide_div"); 66 $("#bt_otpfy_vf_otp_div").addClass("bt_otpfy_hide_div");58 $("#bt_otpfy_vf_otp_div").addClass("bt_otpfy_hide_div"); 67 59 clearInterval(interval); 68 if (!$("#bt_otpfy_resend_otp").hasClass("bt_otpfy_disabled")) {60 if (!$("#bt_otpfy_resend_otp").hasClass("bt_otpfy_disabled")) { 69 61 $("#bt_otpfy_resend_otp").addClass("bt_otpfy_disabled"); 70 } 71 72 }); 73 74 }); 62 } 63 // Reset state 64 resetOtpStep(); 65 }); 66 67 }); 68 69 // ── Helpers ─────────────────────────────────────────────────────────────── 70 71 function resetOtpStep() { 72 isNewUser = false; 73 $("#bt_otpfy_reg_fields").hide(); 74 var loginText = $('#bt_otpfy_vf_code_btn').data('text-login'); 75 $('#bt_otpfy_vf_code_btn') 76 .removeAttr("disabled") 77 .html(loginText + ' <span id="bt_otpfy_vf_loader"></span>') 78 .data('text', loginText); 79 $("#bt_otpfy_vf_code_input").val(''); 80 $("#bt_otpfy_reg_first_name").val(''); 81 $("#bt_otpfy_reg_email").val(''); 82 } 83 84 function showOtpStep(newUser) { 85 isNewUser = newUser; 86 $("#bt_otpfy_send_otp_div").addClass("bt_otpfy_hide_div"); 87 $("#bt_otpfy_vf_otp_div").removeClass("bt_otpfy_hide_div").css('display', 'block'); 88 89 if (newUser) { 90 // Show registration fields and update heading/button 91 $("#bt_otpfy_reg_fields").show(); 92 $('#bt_otpfy_vf_heading_text').html("Create Your Account"); 93 $('#bt_otpfy_vf_sub_heading_text').html("Enter your details and the OTP you received."); 94 var regText = $('#bt_otpfy_vf_code_btn').data('text-register'); 95 $('#bt_otpfy_vf_code_btn').html(regText + ' <span id="bt_otpfy_vf_loader"></span>').data('text', regText); 96 } else { 97 // Hide registration fields, keep default heading/button 98 $("#bt_otpfy_reg_fields").hide(); 99 var loginText = $('#bt_otpfy_vf_code_btn').data('text-login'); 100 $('#bt_otpfy_vf_code_btn').html(loginText + ' <span id="bt_otpfy_vf_loader"></span>').data('text', loginText); 101 } 102 103 startResentOtpTimer(); 104 } 105 106 // ── Timer ───────────────────────────────────────────────────────────────── 107 75 108 var interval; 76 function startResentOtpTimer() {109 function startResentOtpTimer() { 77 110 var timer = 30; 78 $('#bt_otpfy_resend_timer').html("Resend in "+timer + " sec(s)"); 79 if(interval){ 80 clearInterval(interval); 81 } 82 interval = setInterval( function() { 83 timer = timer - 1; 84 $('#bt_otpfy_resend_timer').html("Resend in "+timer + " sec(s)"); 85 86 if(timer === 0){ 111 $('#bt_otpfy_resend_timer').html("Resend in " + timer + " sec(s)"); 112 if (interval) clearInterval(interval); 113 interval = setInterval(function () { 114 timer -= 1; 115 $('#bt_otpfy_resend_timer').html("Resend in " + timer + " sec(s)"); 116 if (timer === 0) { 87 117 $('#bt_otpfy_resend_timer').html(""); 88 118 clearInterval(interval); … … 91 121 }, 1000); 92 122 } 93 function api_call_send_vf_otp(value) { 94 95 var nonce = bitss_otpfy_vars.send_login_otp_nonce; 123 124 // ── AJAX: Send OTP ──────────────────────────────────────────────────────── 125 126 function api_call_send_vf_otp(value) { 127 var nonce = bitss_otpfy_vars.send_login_otp_nonce; 96 128 $.get( 97 129 bitss_otpfy_vars.ajax_url, 98 { action: 'api_call_send_verification_code', input: value, nonce: nonce, otp_login_redirect : $('#otp_login_redirect').val()},130 { action: 'api_call_send_verification_code', input: value, nonce: nonce, otp_login_redirect: $('#otp_login_redirect').val() }, 99 131 function (res) { 100 132 $('#bt_otpfy_send_vf_code_btn').removeAttr("disabled"); 133 $("#bt_otpfy_send_loader").removeClass("btn-ring"); 134 101 135 if (!res) { 102 $('#bt_otpfy_send_vf_code_btn').removeAttr("disabled"); 103 $("#bt_otpfy_send_loader").removeClass("btn-ring"); 104 $('#bt_otpfy_send_server_mess').html("Please refresh the page, and try again."); 105 106 } 107 if (res.status) { 108 $('#bt_otpfy_send_vf_code_btn').removeAttr("disabled"); 109 $("#bt_otpfy_send_loader").removeClass("btn-ring"); 110 $("#bt_otpfy_send_otp_div").addClass("bt_otpfy_hide_div"); 111 $("#bt_otpfy_vf_otp_div").removeClass("bt_otpfy_hide_div"); 112 $("#bt_otpfy_vf_otp_div").css('display','block'); 113 startResentOtpTimer(); 114 } 115 else { 116 $('#bt_otpfy_send_vf_code_btn').removeAttr("disabled"); 117 $("#bt_otpfy_send_loader").removeClass("btn-ring"); 136 $('#bt_otpfy_send_server_mess').html("Please refresh the page and try again."); 137 return; 138 } 139 if (res.status) { 140 // Show unified OTP step — new user vs existing user 141 showOtpStep(res.user_not_found === true); 142 } else { 118 143 $('#bt_otpfy_send_server_mess').html(res.message); 119 }120 } 121 ).fail( function(err) {144 } 145 } 146 ).fail(function () { 122 147 $('#bt_otpfy_send_vf_code_btn').removeAttr("disabled"); 123 $("#bt_otpfy_send_loader").removeClass("btn-ring"); 124 $('#bt_otpfy_send_server_mess').html( 'An error occured, please refresh try again.' ); 125 }); 126 } 127 128 function api_call_vf_otp(value, code) { 129 var nonce = bitss_otpfy_vars.vf_login_otp_nonce; 148 $("#bt_otpfy_send_loader").removeClass("btn-ring"); 149 $('#bt_otpfy_send_server_mess').html('An error occurred, please refresh and try again.'); 150 }); 151 } 152 153 // ── AJAX: Verify OTP (existing user) ───────────────────────────────────── 154 155 function api_call_vf_otp(value, code) { 156 var nonce = bitss_otpfy_vars.vf_login_otp_nonce; 130 157 $.get( 131 158 bitss_otpfy_vars.ajax_url, 132 { action: 'api_call_verification_code', input: value, code: code, nonce: nonce}, 133 (res)=> { 134 if (!res) { 135 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 136 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 137 $('#bt_otpfy_vf_server_mess').html("Please refresh the page, and try again."); 138 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text')); 139 } 140 if (!res.status) { 141 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 142 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 143 $('#bt_otpfy_vf_server_mess').html(res.message); 144 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text')); 145 } 146 else { 147 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 148 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 159 { action: 'api_call_verification_code', input: value, code: code, nonce: nonce }, 160 function (res) { 161 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 162 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 163 164 if (!res || !res.status) { 165 $('#bt_otpfy_vf_server_mess').html(res ? res.message : "Please refresh and try again."); 166 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text') + ' <span id="bt_otpfy_vf_loader"></span>'); 167 } else { 149 168 $('#bt_otpfy_vf_code_btn').html("Verified, redirecting..."); 150 169 window.location = res.data; 151 } 152 } 153 ).fail( function(err) { 154 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text')); 170 } 171 } 172 ).fail(function () { 155 173 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 156 174 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 157 $('#bt_otpfy_vf_server_mess').html( 'An error occured, please refresh try again.' ); 158 }); 159 } 160 161 162 })( jQuery ); 175 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text') + ' <span id="bt_otpfy_vf_loader"></span>'); 176 $('#bt_otpfy_vf_server_mess').html('An error occurred, please refresh and try again.'); 177 }); 178 } 179 180 // ── AJAX: Register & Login (new user) ───────────────────────────────────── 181 182 function api_call_register_and_login(phone, first_name, email, otp) { 183 var nonce = bitss_otpfy_vars.register_and_login_nonce; 184 $.get( 185 bitss_otpfy_vars.ajax_url, 186 { 187 action: 'api_call_register_and_login', 188 phone: phone, 189 first_name: first_name, 190 email: email, 191 otp: otp, 192 nonce: nonce 193 }, 194 function (res) { 195 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 196 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 197 198 if (!res || !res.status) { 199 $('#bt_otpfy_vf_server_mess').html(res ? res.message : 'An error occurred. Please try again.'); 200 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text') + ' <span id="bt_otpfy_vf_loader"></span>'); 201 } else { 202 $('#bt_otpfy_vf_code_btn').html("Registered! Redirecting..."); 203 window.location = res.data; 204 } 205 } 206 ).fail(function () { 207 $('#bt_otpfy_vf_code_btn').removeAttr("disabled"); 208 $("#bt_otpfy_vf_loader").removeClass("btn-ring"); 209 $('#bt_otpfy_vf_code_btn').html($('#bt_otpfy_vf_code_btn').data('text') + ' <span id="bt_otpfy_vf_loader"></span>'); 210 $('#bt_otpfy_vf_server_mess').html('An error occurred, please refresh and try again.'); 211 }); 212 } 213 214 })(jQuery); -
otpfy-your-website/trunk/public/partials/otpfy-for-wordpress-public-display.php
r3228487 r3472376 78 78 <div class="bt_otpfy_heading"> 79 79 <h3> 80 <b >80 <b id="bt_otpfy_vf_heading_text"> 81 81 <?php echo esc_html($settings->get_vf_heading_text()) ?> 82 82 </b> 83 83 </h3> 84 <p >84 <p id="bt_otpfy_vf_sub_heading_text"> 85 85 <?php echo esc_html($settings->get_vf_sub_heading_text()) ?> 86 86 </p> 87 87 </div> 88 89 <!-- Registration fields: hidden by default, shown only for new users --> 90 <div id="bt_otpfy_reg_fields" style="display:none"> 91 <div class="bt_otpfy_lg_input"> 92 <input class="registration_details" id="bt_otpfy_reg_first_name" style="width:100%;margin-bottom:8px" type="text" placeholder="Full Name" /> 93 </div> 94 <div class="bt_otpfy_lg_input"> 95 <input class="registration_details" id="bt_otpfy_reg_email" style="width:100%;margin-bottom:8px" type="email" placeholder="Email Address" /> 96 </div> 97 </div> 98 88 99 <div class="bt_otpfy_lg_input"> 89 100 <input id="bt_otpfy_vf_code_input" style="width:100%;max-width:100%" type="number" pattern="[0-9]*" inputmode="numeric" placeholder="<?php echo esc_html($settings->get_vf_input_ph()) ?>" /> 90 101 </div> 91 102 <div class="bt_otpfy_lg_button"> 92 <button id="bt_otpfy_vf_code_btn" data-text="<?php echo esc_html($settings->get_vf_button_text()) ?>" class="btn button"> 103 <button id="bt_otpfy_vf_code_btn" 104 data-text-login="<?php echo esc_attr($settings->get_vf_button_text()) ?>" 105 data-text-register="Register & Login" 106 data-text="<?php echo esc_attr($settings->get_vf_button_text()) ?>" 107 class="btn button"> 93 108 <?php echo esc_html($settings->get_vf_button_text()) ?> <span id="bt_otpfy_vf_loader"></span> 94 109 </button> … … 110 125 </div> 111 126 127 128 112 129 <p class="otpfy-form-footer"><?php do_action('otpfy-form-footer'); ?></p> 113 130 <?php else :
Note: See TracChangeset
for help on using the changeset viewer.