I’m trying to load my custom script in the admin panel using the same method that WordPress itself loads scripts in the admin area.
This is an example script being loaded by wp-includes/script-loader.php
:
$scripts->add(
'password-strength-meter',
"/wp-admin/js/password-strength-meter$suffix.js",
array( 'jquery', 'zxcvbn-async' ),
false,
1
);
So I tried to add my own script by the same method. I :
- Created a file named
user-profile-validator.js
inside/wp-admin/js/
(also created a minified version) - Tried to enqueue it by using the following code:
$scripts->add(
'user-profile-validator',
"/wp-admin/js/user-profile-validator$suffix.js",
array( 'jquery' ),
false,
1
);
But nothing happened, it’s neither added to URL, nor I can find my script amongst loaded scripts.
Why is this happening?
PS: I’m doing a patch, that is why I’m modifying the core files.