我希望使用WordPress API检查密码的强度。我似乎找不到允许我这样做的函数。代码为
<?php
add_action( \'custom_api_init\', function () {
// Check Password Strength
register_rest_route(
\'custom/v2\',
\'/strength/\',
array(
\'methods\' => \'POST\',
\'callback\' => \'custom_api_strength\'
)
);
}
function custom_api_strength($data){
if(
isset(
$data[\'password\'],
$data[\'username\'],
$data[\'email\'],
$data[\'fname\'],
$data[\'lname\']
)
){
// Check Password Strength
return array(\'result\'=>$strength);
}else{ return array( \'result\'=>\'0\'); }
}
?>