Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #48345, comment 3


Ignore:
Timestamp:
05/20/2023 06:22:22 AM (21 months ago)
Author:
devsabbirahmed
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #48345, comment 3

    initial v1  
    99}}}
    1010
     11
     12
     13So we can add a function that directly imports JavaScript code to the login page and loads it there.
     14{{{#!php
     15<?php
     16function add_custom_login_script() {
     17    wp_enqueue_script('custom-login-script', get_stylesheet_directory_uri() . '/js/custom-login-script.js', array('jquery'), '1.0', true);
     18}
     19add_action('login_enqueue_scripts', 'add_custom_login_script');
     20
     21}}}
     22
     23Then we can add jQuery/JS code
     24
     25
     26{{{
     27jQuery(document).ready(function($) {
     28    var passwordField = $('#user_pass');
     29    var capsLockAlert = $('<div id="caps-lock-alert">Caps Lock is currently on.</div>').hide();
     30   
     31    passwordField.after(capsLockAlert);
     32   
     33    passwordField.on('keyup', function(event) {
     34        var capsLockStatus = event.getModifierState && event.getModifierState('CapsLock');
     35       
     36        if (capsLockStatus) {
     37            capsLockAlert.show();
     38        } else {
     39            capsLockAlert.hide();
     40        }
     41    });
     42});
     43
     44}}}
     45
    1146That will be more readable because an icon sometime not be that much eye interactive.